websitedevelopment icon
4th
Jul 08

Nested Lists in XHTML

Posted Friday 4th July 2008
This article may be old and/or out-dated
The reference being viewed was created as a redirect from an old post. The content may be out-of-date, inaccurate and/or old.

Putting lists inside lists does not validate with the W3C Markup Validation Service. The only method to nest lists relatively with valid XHTML is to nest the entire list within a list element.

Example:

1
2
3
4
5
6
7
8
<ol>
	<li>List One</li>
	<li>List Two</li>
	<li>
		<ul><li>Sub-list One</li></ul>
	</li>
	<li>List Three</li>
</ol>

The following does NOT validate:

1
2
3
4
5
6
<ol>
	<li>List One</li>
	<li>List Two</li>
	<ul><li>Sub-list One</li></ul>
	<li>List Three</li>
</ol>

Trying to validate it produces the error “document type does not allow element “ul” here; assuming missing “li” start-tag.”. Although nesting it correctly, like in the first code example, it’s very difficult to style or make attractive and orderly.

Bookmark or share this page:

SociBook del.icio.us Digg Facebook Google Yahoo Buzz StumbleUpon

MSN Contact: contact [at] danielgibbs.net



No Comments

No comments yet.

TrackBack URL

Leave a comment