提问人:xan 提问时间:7/23/2016 更新时间:7/23/2016 访问量:39
HTML 脚本未正确验证
HTML Script Not Validating Properly
问:
我正在尝试在 HTML 中做一个嵌套列表并在 https://validator.w3.org 上验证它。当我验证它时,我得到了关于如何嵌套标签的错误。
<!DOCTYPE html>
<html lang ="en">
<head>
<meta charset="utf-8">
<title>Ex 2</title>
</head>
<body>
<ul>
<li>Outer-1
<li>Outer-2</li>
<ul>
<li>Inner-1
<li>Inner-2</li>
<li>Inner-3</li>
<ul>
<li>Deep-1</li>
</ul>
</li>
<li>Inner-4
<ul>
<li>Deep-2</li>
</ul>
</li>
</ul>
</li>
<li>Outer-3</li>
</ul>
<ul>
<li style = "list-style-type: decimal">Outer-1
<li style = "list-style-type: decimal">Outer-2</li>
<ul>
<li style = "list-style-type: lower-alpha">Inner-1
<li style = "list-style-type: lower-alpha">Inner-2</li>
<ul>
<li style = "list-style-type: lower-roman">Deep-1</li>
<li style = "list-style-type: lower-roman">Deep-2</li>
</ul>
</li>
</ul>
</li>
<li style = "list-style-type: decimal">Outer-3</li>
<ul>
<li style = "list-style-type: lower-roman">Inner-3</li>
</ul>
</ul>
</body>
</html>
在浏览了 stackoverflow 上的一些帖子后,我发现了这个(ul in ul 的正确语义)帖子,说我应该将我的 ul 标签嵌套在 li 中,但我发现这并没有给出我想要的结果,这是我目前所拥有的,但我也希望它正确验证。谁能帮助正确格式,以便正确验证?
答:
0赞
npat89
7/23/2016
#1
<meta charset="utf-8" />
元标记不应该是这样的吗?
评论
0赞
Mr Lister
7/23/2016
不,OP 的源不是 XHTML。
1赞
Rakib
7/23/2016
#2
<!DOCTYPE html>
<html lang ="en">
<head>
<meta charset="utf-8">
<title>Ex 2</title>
</head>
<body>
<ul>
<li>Outer-1</li>
<li>Outer-2
<ul>
<li>Inner-1
<li>Inner-2</li>
<li>Inner-3
<ul>
<li>Deep-1</li>
</ul>
</li>
<li>Inner-4
<ul>
<li>Deep-2</li>
</ul>
</li>
</ul>
</li>
<li>Outer-3</li>
</ul>
<ul>
<li style = "list-style-type: decimal">Outer-1</li>
<li style = "list-style-type: decimal">Outer-2
<ul>
<li style = "list-style-type: lower-alpha">Inner-1</li>
<li style = "list-style-type: lower-alpha">Inner-2
<ul>
<li style = "list-style-type: lower-roman">Deep-1</li>
<li style = "list-style-type: lower-roman">Deep-2</li>
</ul>
</li>
</ul>
</li>
<li style = "list-style-type: decimal">Outer-3</li>
</ul>
我已经修改了一些标签,现在它工作正常。
评论
0赞
xan
7/23/2016
仍然在验证器上正确验证
评论