我编写的以下代码不会通过W3C验证器,而是会给我以下错误:
第18行,第7列:未打开的元素“P”的结束标记
在</p>
标记之后立即关闭</ul>
标记。我真的很难解决这个问题。这是标记:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="de">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>foo</title>
</head>
<body>
<div class="foo1">
<div class="foo2">
<h1>some heading</h1>
<p>
<ul>
<li>some stuff</li>
<li>yet another stuff</li>
</ul>
</p>
<p>yet another heading</p>
</div>
</div>
</body>
</html>
答案 0 :(得分:2)
检查this Q&A
在HTML4中,将ul
置于p
内无效。
答案 1 :(得分:1)
W3C验证程序不允许您将<ul>
放入{4.0}严格的<p></p>
内。它也不需要</p>
。
因此,您可以删除</p>
或删除<p>
和</p>
来解决您的问题。
答案 2 :(得分:1)
在Html中的<p>
标记中不允许使用此功能。最好尝试使用此功能。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="de">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>foo</title>
</head>
<body>
<div class="foo1">
<div class="foo2">
<h1>some heading</h1>
<ul>
<li>some stuff</li>
<li>yet another stuff</li>
</ul>
<p>yet another heading</p>
</div>
</div>
</body>
</html>