html - 验证错误 : Element hr not allowed as child of element ul in this context.(抑制来自该子树的更多错误。)

标签 html validation

我在 HTML Validator site 上遇到以下错误.

这是我收到的错误消息:

Element hr not allowed as child of element ul in this context. (Suppressing further errors from this subtree.)

这是我的 html 代码:

<nav>
    <ul>
        <li><a href="index.php">Home</a></li><hr>
        <li><a href="displayallbooks.php">Display All Books</a></li><hr>
        <li><a href="searchbooksform.php">Search Books</a></li><hr>
        <li><a href="credits.php">Credits</a></li><hr>

    </ul>   
</nav>

任何帮助将不胜感激。谢谢。

最佳答案

基于 HTML 验证器,我在问题下方的评论和我在 Jsfiddle 上的尝试,将您的代码更改为这种方式:

<nav>
    <ul>
        <li><a href="index.php">Home</a><hr/></li>
        <li><a href="displayallbooks.php">Display All Books</a><hr/></li>
        <li><a href="searchbooksform.php">Search Books</a><hr/></li>
        <li><a href="credits.php">Credits</a><hr/></li>
    </ul> 
</nav>

我在 HTML validort 网站上使用的源代码是:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>t</title>
</head>
<body>
    <ul>
        <li><a href="index.php">Home</a><hr/></li>
        <li><a href="displayallbooks.php">Display All Books</a><hr/></li>
        <li><a href="searchbooksform.php">Search Books</a><hr/></li>
        <li><a href="credits.php">Credits</a><hr/></li>
    </ul> 
</body>
</html>

它给了我零错误。使用您的标签 nav,验证者提示此标签。

关于html - 验证错误 : Element hr not allowed as child of element ul in this context.(抑制来自该子树的更多错误。),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27836973/

相关文章:

javascript - 如果宽度大于原始图像,则更改图像 src

html - 为什么我的页脚没有粘在页面底部?

validation - Laravel - 在回调后在验证器中使用变量

javascript - 更改 Javascript 中的数字捕获以接受点

asp.net-mvc - Html.BeginForm multipart/form-data 文件上传表单组验证

javascript - 硬件加速无法正常工作

javascript - 我如何将 Javascript 对象写入文档。无法在 'write' 上执行 'Document'

javascript - Null Page_Validators 在触发 asp 按钮 onclick 时导致错误

asp.net - 在局部 View 中强制使用无 Html.BeginForm/Ajax.BeginForm 的无障碍语法

javascript - 如何使用w3 slider 在 slider 图像中添加自动播放?