HTML脚本无法正确验证

时间:2016-07-22 18:25:38

标签: html list validation nested xhtml

我正在尝试在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上的一些帖子后,我发现这个(correct semantics for ul in ul)帖子说我应该在li中嵌套我的ul标签,但是我发现这不会给出我想要的结果,这就是什么我目前,但我也希望它正确验证。任何人都可以帮助使用正确的格式,以便正确验证吗?

2 个答案:

答案 0 :(得分:1)

&#13;
&#13;
<!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>
&#13;
&#13;
&#13;

我修改了一些标签,现在它正常工作。

答案 1 :(得分:0)

<meta charset="utf-8" />

不应该是Meta标签吗?