Home HTML Tags <ol> HTML ol Tag Definition
Definition and Usage The <ol> element represents an ordered list — items where sequence matters, usually shown with numbers or letters. Each item is an <li> .
Use <ol> for recipes, steps, rankings, or directions. If order does not change meaning, use <ul> instead. Control numbering with type , start , and reversed .
Baseline · Widely available. Not deprecated. Stable across browsers since about July 2015 (and much earlier in practice).
Deprecated: compact. Do not use compact on <ol>. Use CSS (for example line-height) for tighter spacing.
Syntax
HTML Syntax <ol>
<li>First item</li>
<li>Second item</li>
</ol> Both start and end tags are required. Children are zero or more <li> elements (plus optional <script> / <template>). Implicit ARIA role is list.
Reference
Attributes The attributes you will use most often on <ol>:
Attribute Description Notes typeMarker style: 1, a, A, i, I Prefer CSS list-style-type when style is only visual startInteger where numbering begins (always Arabic: 1, 2, 3…) Example: start="4" with type="a" starts at “d” reversedBoolean — numbers from high to low Useful for countdowns and rankings compactDeprecated — once hinted at a compact layoutUse CSS line-height instead
Try it
Live Preview Change the numbering type and see how the same items look.
Code
HTML Examples Short, copy-ready snippets. Use Try It Yourself for a live editor.
1. Basic list 2. type attribute 3. start & reversed 4. Nested lists Example 1 — Basic Ordered List Steps where order matters — a classic recipe list.
<ol>
<li>Mix flour, baking powder, sugar, and salt.</li>
<li>In another bowl, mix eggs, milk, and oil.</li>
<li>Stir both mixtures together.</li>
<li>Fill muffin tray 3/4 full.</li>
<li>Bake for 20 minutes.</li>
</ol> Mix flour, baking powder, sugar, and salt. In another bowl, mix eggs, milk, and oil. Stir both mixtures together. Fill muffin tray 3/4 full. Bake for 20 minutes. How It Works Open with <ol> because the sequence matters.Wrap each step in <li>…</li>.Browsers number items automatically (1, 2, 3… by default).Close with </ol> after the last item.Example 2 — Letter / Roman Markers Set type when the marker style itself carries meaning.
<ol type="i">
<li>Introduction</li>
<li>List of Grievances</li>
<li>Conclusion</li>
</ol> Introduction List of Grievances Conclusion How It Works Add type="i" for lowercase Roman numerals.Other values: 1, a, A, I.Keep the same <li> items — only markers change.For pure styling , prefer CSS list-style-type instead.Example 3 — start and reversed Continue numbering from a value, or count down.
<p>Finishing places outside the winners’ circle:</p>
<ol start="4">
<li>Speedwalk Stu</li>
<li>Saunterin’ Sam</li>
<li>Slowpoke Rodriguez</li>
</ol>
<p>Countdown:</p>
<ol reversed>
<li>Lift off</li>
<li>Ignition</li>
<li>Final checks</li>
</ol> start="4"
Speedwalk Stu Saunterin' Sam Slowpoke Rodriguez reversed
Lift off Ignition Final checks How It Works Set start="4" so the first item shows as 4 (then 5, 6…).start is always an Arabic integer , even with letter/Roman type.Add reversed (no value needed) to number high → low.Combine carefully when both meaning and display matter to readers.Example 4 — Nested Lists Put a nested list inside an <li>, not directly under <ol>.
<ol>
<li>First item</li>
<li>Second item
<ol>
<li>Second item, first subitem</li>
<li>Second item, second subitem</li>
</ol>
</li>
<li>Third item</li>
</ol> First item Second itemSecond item, first subitem Second item, second subitem Third item How It Works Keep top-level items as normal <li> children of <ol>.Open a nested <ol> (or <ul>) inside an <li> .Close the nested list , then close that parent <li>.Never place <ol> as a direct child of another <ol>. Edge Cases & Pitfalls Most ordered-list bugs are wrong list type, invalid nesting, or styling with obsolete attributes.
meaning ol vs ul If shuffling items changes meaning, use <ol>. If not, use <ul> .
nesting Nest inside li A nested list must live inside an <li>. Lists cannot be direct children of ol/ul.
type type vs CSS Use type when letters/numerals matter for references. Otherwise style with CSS list-style-type.
start start is always numeric start="4" with type="i" begins at Roman “iv” — the attribute value is still the integer 4.
obsolete No compact Skip compact. Tighten spacing with CSS instead.
Compatibility
Browser Support The <ol> element is core HTML list content in every browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
<ol> Widely available since about July 2015 (and long before). type, start, and reversed are supported across modern browsers.
98% Global support (approx.)
Google Chrome All
Full support
Mozilla Firefox All
Full support
Apple Safari All
Full support
Microsoft Edge All
Full support
Opera All
Full support
Samsung Internet All
Full support
Internet Explorer All
Supported ol Widely supported
Bottom line: Safe everywhere. Use ol when order matters; nest lists inside li; prefer CSS for pure styling.
Remember
Key Takeaways Meaning: ol = ordered list; each item is an li.
Controls: type, start, and reversed shape numbering.
Nesting: put nested lists inside an li, never directly in ol.
Style: skip compact; use CSS when markers are only visual.
One line: use ol when order matters, wrap items in li, and nest lists inside those items.
UA style
Default CSS Settings Typical user-agent defaults (exact values vary by browser):
ol {
display: block;
list-style-type: decimal;
margin-block: 1em;
padding-inline-start: 40px;
} Override markers with list-style-type / list-style when the change is presentational.
Frequently Asked Questions What is the HTML ol tag? The ol (ordered list) element marks a list where order matters — typically shown with numbers or letters. Put each item in an li element.
When should I use ol instead of ul? Use ol when changing the item order would change the meaning (recipes, steps, rankings). Use ul when order is not meaningful.
What do type, start, and reversed do? type sets the marker style (1, a, A, i, I). start sets the first number (always as an Arabic integer). reversed numbers from high to low.
Should I use type or CSS list-style-type? If the marker style is only visual, prefer CSS list-style-type. Use the type attribute when the letter or numeral style matters for meaning (for example legal references).
How do I nest lists? Place the nested ol or ul inside an li of the parent list — never as a direct child of another ol or ul.
Is compact still valid? No. The compact attribute is obsolete. Use CSS such as line-height instead.
Next: optgroup Group related options inside a select with the HTML optgroup element.
optgroup tutorial → About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
12 people found this page helpful
Helpful Share Copy link Suggestion