Wednesday, August 13, 2008

Ordered Lists - The <ol> tag

The ol tag is used to create a list when the sequence of the items are important. The browser numbers each item of the ordered list sequentially.
Each item of the ordered list must be enclosed in the li element. The ol element must not be inside a p element. It can be within the body element, the blockquote element or the div element.
All browsers indent the list from the left.
Ordered and unordered lists can be nested within each other. The li element can contain another ordered or unordered list. Actually, the li tag can contain virtually any element that the body element can contain.
<li>Super item</a>
<ul class="sub">
<li><a href="sub1.html">Sub-item 1</a></li>
<li><a href="sub2.html">Sub-item 2</a></li>
<li><a href="sub3.htm">Sub-item 3</a></li>
<li>Item 2
<li>Sub-item 2</li>
<li>Sub-item 3</li>
<table border="border"><tr><td>row1item1</td><td>row1Item2</td></tr><tr><td>row2Item1</td><td>row2item2</td></tr></table>

This is rendered by all major browsers like this:

No comments: