我在 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/