Ordered list
From Wikipedia, the free encyclopedia
In HTML an ordered list <ol> .. </ol> is a HTML element for a list of items where each item is automatically prefixed by an indication of its position in the list.
An unordered list <ul> .. </ul> is a HTML element for a list of items where each item is prefixed by a fixed symbol, or nothing.
A list-style-type implies the prefixes to be equal or changing, and overrides the distinction between ol and ul.
Examples: decimal (default list-style-type for ol):
<ol> <li>Amsterdam <li>Rotterdam <li>The Hague </ol>
gives
- Amsterdam
- Rotterdam
- The Hague
Specifying a list-style-type:
lower-alpha:
<ol style="list-style-type:lower-alpha"> <li>Amsterdam <li>Rotterdam <li>The Hague </ol>
gives
- Amsterdam
- Rotterdam
- The Hague
Similarly:
upper-alpha:
- Amsterdam
- Rotterdam
- The Hague
lower-roman:
- Amsterdam
- Rotterdam
- The Hague
upper-roman:
- Amsterdam
- Rotterdam
- The Hague
disc (default list-style-type for 1st-level ul):
- Amsterdam
- Rotterdam
- The Hague
circle (default list-style-type for 2nd-level ul):
- Amsterdam
- Rotterdam
- The Hague
square (default list-style-type for 3rd and higher level ul):
- Amsterdam
- Rotterdam
- The Hague
"none":
- Amsterdam
- Rotterdam
- The Hague
A starting value can be specified (naturally this has no effect if the prefix does not depend on the item's position in the list):
<ol start=2> <li>Amsterdam <li>Rotterdam <li>The Hague </ol>
gives
- Amsterdam
- Rotterdam
- The Hague
Similarly (the starting value has to be in decimal form):
- Amsterdam
- Rotterdam
- The Hague
- Amsterdam
- Rotterdam
- The Hague
- Amsterdam
- Rotterdam
- The Hague
- Amsterdam
- Rotterdam
- The Hague
[edit] Comparison with a table
Apart from providing automatic numbering, the numbered list also aligns the contents of the items, comparable with using table syntax:
<ol start="9"> <li>Amsterdam <li>Rotterdam <li>The Hague </ol>
gives
- Amsterdam
- Rotterdam
- The Hague
{| |----- | align="right" | 9. || Amsterdam |----- | align="right" | 10. || Rotterdam |----- | align="right" | 11. || The Hague |}
gives
9. | Amsterdam |
10. | Rotterdam |
11. | The Hague |
This non-automatic numbering has the advantage that if a text refers to the numbers, insertion or deletion of an item does not disturb the correspondence.