开发者

Lists inside lists don't validate with w3c?

开发者 https://www.devze.com 2022-12-24 16:57 出处:网络
I\'ve got some lists inside lists to make some fancy drop-down menus. e.g <ul> <li>something

I've got some lists inside lists to make some fancy drop-down menus.

e.g

<ul>
    <li>something
        <ul>
            <li>sub menu</li>
        </ul>
    </li>
</ul>

Problem is开发者_运维百科, w3c doesn't like it. Is there a way to make this validate or this is just one of these hacks that browsers can render, but w3c dislikes?


The code you posted is correct and valid. According to W3S nesting lists like this:

<ul>
  <li>Coffee</li>
  <li>Tea
    <ul>
      <li>Black tea</li>
      <li>Green tea</li>
    </ul>
  </li>
  <li>Milk</li>
</ul>

is the right way (exactly as you do it). Error is somewhere else. Please provide more code.

Even with DOCTYPE XHTML 1.0 Strict W3C validates this code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Title</title>
</head>

<body>
<ul>
    <li>1</li>
    <li>2</li>
    <li>3
        <ul>
            <li>3.1</li>
            <li>3.2</li>
        </ul>
    </li>
    <li>4</li>
</ul>
</body>
</html>

as correct.


this is valid using doctype xhtml 1 transitional

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号