Things have changed somewhat since the first writeup was written. The correct way to do a list in (X)HTML is now like this:

<ol>
<li>Ordered list item one</li>
<li>Ordered list item two</li>
<li>Ordered list item three</li>
</ol>

Note that every opening tag has a corresponding closing tag, and that all tags are lower case. If you want to nest list items then remember that every list block element (ie, <ol> and <ul>) must itself be inside a list item element:

<ol>
  <li>Ordered list item one</li>
  <li>Ordered list item two
    <ul>
      <li>Nested, unordered list item one</li>
      <li>Nested, unordered list item two</li>
      <li>Nested, unordered list item three</li>
    </ul>
  </li>
  <li>Ordered list item three</li>
</ol>

Alternatively, you can take the view that every list is itself a list item:

<ol>
  <li>Ordered list item one</li>
  <li>Ordered list item two</li>
  <li>
    <ul>
      <li>Nested, unordered list item one</li>
      <li>Nested, unordered list item two</li>
      <li>Nested, unordered list item three</li>
    </ul>
  </li>
  <li>Ordered list item three</li>
</ol>

Indentation (and in fact line breaks) are all entirely optional; however they do make the code easier to read, and therefore maintain). The above code will render as:

  1. Ordered list item one
  2. Ordered list item two
    • Nested, unordered list item one
    • Nested, unordered list item two
    • Nested, unordered list item three
  3. Ordered list item three

The node on XHTML has some excellent reasons why you, Joe Noder, should be writing strict XHTML code instead of sloppy old HTML 4. Especially since it's so easy! :)

Log in or registerto write something here or to contact authors.