<div id="leftNav">
<ul id="mainmenu">
<li><a href="index.html">Home</a></li>
<li><a href="articles.html">News</a></li>
<li><a href="media.html">Media</a>
<ul class="submenu">
<li><a href="videos.html">Videos</a></li>
<li><a href="gallery.html">Gallery</a></li>
</ul>
<li><a href="contact.html">Contact</a>
<ul class="submenu">
<li><a href="email.html">Email</a></li>
<li><a href="location.html">Phone</a></li>
<li><a href="location.html">Location</a></li>
</ul>
<li><a href="about.html">About</a></li>
</ul>
</div>
此代码非常适合我的垂直下拉菜单。但是代码验证讨厌吗?
我的结果在这里进行验证,请看一下。
文档类型不允许元素“li”在这里;缺少一个“ul”, “ol”,“menu”,“dir”开头标记结束标记为“li”省略,但OMITTAG 没有指定
错误/警告类型计数总错误:4总警告:1总计 嵌套错误:0总消息:0
答案 0 :(得分:2)
您忘记关闭每个主要<li>
元素。当您关闭内部<ul>
列表时,您必须关闭对应的<li>
元素,以传递到主列表的下一个项目。这部分将是(x)HTML有效:
<div id="leftNav">
<ul id="mainmenu">
<li><a href="index.html">Home</a></li>
<li><a href="articles.html">News</a></li>
<li><a href="media.html">Media</a>
<ul class="submenu">
<li><a href="videos.html">Videos</a></li>
<li><a href="gallery.html">Gallery</a></li>
</ul></li>
<li><a href="contact.html">Contact</a>
<ul class="submenu">
<li><a href="email.html">Email</a></li>
<li><a href="location.html">Phone</a></li>
<li><a href="location.html">Location</a></li>
</ul></li>
<li><a href="about.html">About</a></li>
</ul>
</div>
答案 1 :(得分:1)
你错过了一些关闭</li>
的。以下是更正后的版本:
<div id="leftNav">
<ul id="mainmenu">
<li><a href="index.html">Home</a></li>
<li><a href="articles.html">News</a></li>
<li><a href="media.html">Media</a>
<ul class="submenu">
<li><a href="videos.html">Videos</a></li>
<li><a href="gallery.html">Gallery</a></li>
</ul>
</li>
<li><a href="contact.html">Contact</a>
<ul class="submenu">
<li><a href="email.html">Email</a></li>
<li><a href="location.html">Phone</a></li>
<li><a href="location.html">Location</a></li>
</ul>
</li>
<li><a href="about.html">About</a></li>
</ul>
</div>
答案 2 :(得分:1)
试试这个:
<div id="leftNav">
<ul id="mainmenu">
<li><a href="index.html">Home</a></li>
<li><a href="articles.html">News</a></li>
<li><a href="media.html">Media</a>
<ul class="submenu">
<li><a href="videos.html">Videos</a></li>
<li><a href="gallery.html">Gallery</a></li>
</ul></li> <!-- here -->
<li><a href="contact.html">Contact</a>
<ul class="submenu">
<li><a href="email.html">Email</a></li>
<li><a href="location.html">Phone</a></li>
<li><a href="location.html">Location</a></li>
</ul></li> <!-- here -->
<li><a href="about.html">About</a></li>
</ul>
</div>
您必须在嵌套的li
元素后关闭ul
- 标记。