To create an html ordered list, wrap the items in an <ol> element and put each step or entry in its own <li>. Browsers number the items automatically, starting at 1, so you never type the numbers yourself and reordering is just moving lines around.
Use an ordered list when the sequence is part of the meaning: instructions, rankings, procedures or a table of contents. If the order does not matter, an unordered list is the better fit.
An ordered list has the same shape as an unordered one. Only the outer tag changes: ol stands for ordered list, and li is still the list item.
The browser shows the four lines numbered 1. to 4. If you later insert a step between the second and third lines, the numbers update by themselves.
Choose <ol> when swapping two items would change the meaning of the content.
| Content | Right element | Why |
|---|---|---|
| Recipe steps | <ol> | Steps must happen in order |
| Top 10 ranking | <ol> | Position carries meaning |
| Ingredients | <ul> | Order does not matter |
| Site menu | <ul> | Links are a set, not a sequence |
A good test is to ask whether a reader could follow the list from bottom to top and still get the same result. If not, the list is ordered.
The numbering style is controlled by the CSS property list-style-type. The default is decimal.
You can also change colour and size of the numbers with the ::marker pseudo-element, without touching the text of the items.
Each <li> can hold more than a line of text. A step may include a paragraph, a code sample, an image description or a nested list. The numbering keeps counting across all of it.
Only <li> elements (and script-supporting elements) may be direct children of <ol>. Put paragraphs, code and other content inside the li, not between items.
An ordered list can contain another list inside a list item, for example sub-steps. Put the inner <ol> or <ul> inside the parent <li>, after the item's own text.
The inner list restarts its numbering at 1 by default, so the result reads 1, 1, 2, 2.
Screen readers announce an ordered list as a list with a number of items and read each item's position, for example "2 of 4". That information is lost if you type numbers into plain paragraphs. Always use real list markup for sequences, even when you restyle it heavily.
Be careful with list-style: none on an ordered list. If you remove the numbers visually, some assistive technology also stops announcing the position. Keep the numbers visible, or generate your own with CSS counters while keeping the <ol> element.
Yes, with the start attribute on the <ol>, for example <ol start="5">. The attributes start, reversed and type are covered in detail in a related article.
</li> tag required?The specification lets you omit it in many cases, but writing it is clearer and avoids mistakes when you edit the list.
Usually a CSS reset or a rule like list-style: none removes them. Check the styles applied to the ol and its li elements in your browser developer tools.
No. Typing numbers into the text duplicates what the browser does, breaks when you reorder items and confuses screen readers.
An ordered list uses <ol> for the container and <li> for each item, and the browser supplies the numbers. Use it when the order carries meaning, style the numbering with list-style-type or ::marker, and keep real list markup rather than faking numbers in text. Only li elements belong directly inside the ol.