我正在尝试验证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标签,尽管在我写的其他代码中接受了相同的语法。那么这里有什么问题?
答案 0 :(得分:2)
您不能将h2
标记用作块级元素;它是标题标记,其功能与上面的h1
标记相同。向上移动</h2>
结束标记并添加一些文字:
<h2>Some Random Title</h2>
答案 1 :(得分: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>
OR
<?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>