0

我正在尝试在 validator.w3.org 上验证以下 xhtml 代码

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- Let us try the use of heading styles
-->
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title> Headings</title>
</head>
<body>
<h1>Program Pool</h1>
<h2>
<ul>
<li> Basic Programming </li>
<li> Intermediate Programming </li>
<li> Advanced Programming </li>
<li> Modular Programming </li>
</ul>
<!-- <br /> <br /> <br /> -->
</h2>
</body>
</html>

我在第 17 行(出现第一个 ul 标记的行)收到错误消息。主要问题是 ul 标记,尽管在我编写的其他代码中接受了相同的语法。那么这里有什么问题呢?

4

2 回答 2

2

您不能将h2标签用作块级元素;它是一个标题标签,它的功能与h1上面的标签相同。向上移动</h2>结束标签并添加一些文本:

<h2>Some Random Title</h2>
于 2013-08-24T22:21:35.827 回答
0

如果您只删除<H2>标签周围使用的“”标签,问题就会解决<UL>

如果需要注意,请使用 CSS 为您的 UL 设置样式。

删除周围的标签或给出适当的标题并在此处关闭:-

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- Let us try the use of heading styles
-->
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title> Headings</title>
</head>
<body>
<h1>Program Pool</h1>
<ul>
<li> Basic Programming </li>
<li> Intermediate Programming </li>
<li> Advanced Programming </li>
<li> Modular Programming </li>
</ul>

</body>
</html>

或者

    <?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- Let us try the use of heading styles
-->
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title> Headings</title>
</head>
<body>
<h1>Program Pool</h1>
**<h2>heading</h2>**
<ul>
<li> Basic Programming </li>
<li> Intermediate Programming </li>
<li> Advanced Programming </li>
<li> Modular Programming </li>
</ul>

</body>
</html>
于 2013-08-26T21:22:11.370 回答