XHTML: Why is my nested UL invalid?
css, html, validation, xhtml
Solution
<ul id="leftNavi">
<li ><a href="#" class="SCL">left menu1</a></li>
<li class="SCNL">left menu2
<ul id="subnavi">
<li><a href="#" class="inactive">menu2/1</a></li>
<li><a href="#" class="inactive">menu2/2</a></li>
<li><a href="#" class="inactive">menu2/3</a></li>
</ul>
</li>
<li><a href="#" class="HCL">left menu3</a></li>
</ul>
You had a couple of problems:
- The line with 3 as the list item didn't have a correct closing `<li>` element; and
- The `subnav1` list wasn't contained within a `<li>` element. It can't be a direct child of another list, which was the main problem with validating your HTML.
Problem
The following menu works really fine in the browser, but I cant get it to validate as XHTML. I took this example out of my CSS Book. It says it is right, but seemingly it is not. ``` <ul id="leftNavi"> <li> <a href="#" class="SCL">left menu1</a> </li> <li class="SCNL">left menu2</li> <ul id="subnavi"> <li> <a href="#" class="inactive">menu2/1</a> </li> <li> <a href="#" class="inactive">menu2/2</a> </li> <li> <a href="#" class="inactive">menu2/3</a> <li> </ul> <li> <a href="#" class="HCL">left menu3</a> </li> </ul> ``` Here a link to the page: http://www.yiip.de/arbeit/testlayout/standard_template.html I am talking about the left menu.