HTML Reference Β· Text Content
The <ol> element
Reference for the HTML <ol> element: numbered lists where order matters, the start, reversed and type attributes, nesting, markers and technical details.
The <ol> element is an ordered list: a list of <li> items where the sequence carries meaning, such as steps in a recipe, a ranking or a set of instructions. Browsers number the items automatically.
HTML
<ol> <li>Unlock the bike</li> <li>Adjust the seat</li> <li>Ride away</li> </ol>
Try it
Attributes
| Attribute | Values | Description |
|---|---|---|
reversed |
Boolean | Numbers the items in descending order, ending at 1 by default. |
start |
An integer | The number of the first item. With reversed, the default start is the number of items. |
type |
1, a, A, i, I |
The kind of marker: decimal (default), lowercase or uppercase letters, lowercase or uppercase roman numerals. |
It also accepts the global attributes. Individual items can set their own number with the value attribute on <li>.
Usage notes
- Order must matter. Ask: "Would swapping two items change the meaning?" If yes, use
<ol>. If not, use<ul>. typevs CSS. Usetypewhen the numbering style is part of the content (for example, a legal document that refers to "item B"). For purely visual choices, use the CSSlist-style-typeproperty, which also offers many more styles.startis always a number. Even withtype="a", writestart="3"to begin at "c".- Only
<li>children. Any other element, like a heading or a paragraph, must go inside an<li>, not directly in the<ol>. - Accessibility. Screen readers announce the list and its item count, which tells listeners how long the sequence is before they start.
Technical summary
| Content categories | Flow content; palpable content if it has at least one <li> child |
| Permitted content | Zero or more <li> elements and script-supporting elements |
| Tag omission | None; both the start and end tags are required |
| Permitted parents | Any element that accepts flow content |
| Implicit ARIA role | list |
| DOM interface | HTMLOListElement |
| Default display | block |
Browser support
Supported in every browser, including the reversed, start and type attributes.
Related
<li>β list items and thevalueattribute<ul>β unordered lists<menu>β lists of commands<dl>β nameβvalue lists- Lesson: Lists
- Lesson: Ordered List Options
- Lesson: Nested Lists