Quick Overview
If you want to nest lists in HTML, you probably did something like the following (although you may not have done the indenting)
<ul><br />
<li>List Item 1</li><br />
<ul><br />
<li>Sublist Item 1</li><br />
<li>Sublist Item 2</li><br />
<ul><br />
<li>Subsublist Item 1</li><br />
</ul><br />
<li>Sublist Item 3</li><br />
</ul><br />
<li>List item 2</li><br />
<li>List Item 3</li><br />
</ul><br />
In XHTML, this is not valid (the w3 validator will complain about "document type does not allow element "ul" here; assuming missing "li" start-tag
". The reason is that an nested <ul>
belongs within an <li>
tag. You might worry that this would put a higher level bullet on the sublist– it doesn’t. The key is you don’t close the <li>
tag from the previous entry until after the sublist finishes. Compare the following. (note that both are syntactically correct XHTML)
Code | Output |
---|---|
<ul><br />
|
|
Versus | |
<ul><br />
|
|
Enjoy.