Subscribe to the RWT RSS Feed

RWT Webmaster Tools Blog

Resources and Tools You Can Use

 

Creating valid xhtml strict nested lists

To create a nested list that is valid according to the xhtml strict specification, such as the one below:

  • Main List
    • Sub Item
    • Sub Item
    • Sub Item
    • Sub Item
    • Sub Item
    • Sub Item
  • Main List
    • Sub Item
    • Sub Item
    • Sub Item
      • Sub Sub Item
      • Sub Sub Item
    • Sub Item
    • Sub Item
  • Main List
    • Sub Item
    • Sub Item
    • Sub Item
    • Sub Item
    • Sub Item

Follow the code that looks like this:

<ul>
<li>Main List
     <ul>
     <li>Sub Item</li>
     <li>Sub Item</li>
     <li>Sub Item</li>
     <li>Sub Item</li>
     <li>Sub Item</li>
     <li>Sub Item</li>
     </ul>
</li>
<li>Main List
     <ul>
     <li>Sub Item</li>
     <li>Sub Item</li>
     <li>Sub Item
          <ul>
          <li>Sub Sub Item</li>
          <li>Sub Sub Item</li>
          </ul>
     </li>
     <li>Sub Item</li>
     <li>Sub Item</li>
     </ul>
</li>
<li>Main List
     <ul>
     <li>Sub Item</li>
     <li>Sub Item</li>
     <li>Sub Item</li>
     <li>Sub Item</li>
     <li>Sub Item</li>
     </ul>
</li>
</ul>

General Guidelines

-sub lists MUST be encapsulated within the li tags of an item on the base list. I have tried to show this in the blockquote above by indenting each sub list.
- include any formatting within li tags
- use <p> tags to create breaks around an image

comments / trackbacks

5 Responses to “Creating valid xhtml strict nested lists”
  1. Thanks, this helped a lot!

  2. A quick thanks for this. I’m just learning (X)HTML from scratch and was having issues getting my nested lists through the W3 XHTML Validator until I came across this and used it a a reference point for creating my lists and after some effort it worked.

    So yeah Thanks.

  3. Thank you! :)

  4. Awesome work!

    This was causing me a huge headache.

  5. Brilliant, couldn’t figure out what I was doing wrong…till now

Leave a Reply