ol
elementli
element: Palpable content.li
elements.reversed
start
type
interface HTMLOListElement : HTMLElement { attribute boolean reversed; attribute long start; attribute DOMString type; };
The ol
element represents
a list of items, where the items have been intentionally ordered,
such that changing the order would change the meaning of the
document.
The items of the list are the li
element child nodes of the ol
element, in tree order.
The reversed
attribute is a
boolean attribute. If present, it
indicates that the list is a descending list (..., 3, 2, 1). If the
attribute is omitted, the list is an ascending list (1, 2, 3,
...).
The start
attribute, if present,
must be a valid integer giving the ordinal value of the first list item.
The type
attribute can be used to
specify the kind of marker to use in the list, in the cases where
that matters (e.g. because items are to be referenced by their
number/letter). The attribute, if specified, must have a value that
is a case-sensitive match for one of the
characters given in the first cell of one of the rows of the
following table.
Keyword | State | Description | Examples for values 1-3 and 3999-4001 | |||||||
---|---|---|---|---|---|---|---|---|---|---|
1 (U+0031) |
decimal | Decimal numbers | 1. | 2. | 3. | ... | 3999. | 4000. | 4001. | ... |
a
(U+0061) |
lower-alpha | Lowercase latin alphabet | a. | b. | c. | ... | ewu. | ewv. | eww. | ... |
A
(U+0041) |
upper-alpha | Uppercase latin alphabet | A. | B. | C. | ... | EWU. | EWV. | EWW. | ... |
i
(U+0069) |
lower-roman | Lowercase roman numerals | i. | ii. | iii. | ... | mmmcmxcix. | i̅v̅. | i̅v̅i. | ... |
I
(U+0049) |
upper-roman | Uppercase roman numerals | I. | II. | III. | ... | MMMCMXCIX. | I̅V̅. | I̅V̅I. | ... |
The following markup shows a list where the order matters, and
where the ol
element is therefore appropriate. Compare this
list to the equivalent list in the ul
section to see an example of the same items
using the ul
element.
<p>I have lived in the following countries (given in the order of when I first lived there):</p> <ol> <li>Switzerland <li>United Kingdom <li>United States <li>Norway </ol>
Note how changing the order of the list changes the meaning of the document. In the following example, changing the relative order of the first two items has changed the birthplace of the author:
<p>I have lived in the following countries (given in the order of when I first lived there):</p> <ol> <li>United Kingdom <li>Switzerland <li>United States <li>Norway </ol>