HTML ol Tag

Beginner
6 min read
Updated: Oct 2026
4 examples
Live preview

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.

HTML Syntax

syntax.html
<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.

Attributes

The attributes you will use most often on <ol>:

AttributeDescriptionNotes
typeMarker style: 1, a, A, i, IPrefer 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 lowUseful for countdowns and rankings
compactDeprecated — once hinted at a compact layoutUse CSS line-height instead

Global Attributes

The <ol> tag also supports the Global Attributes in HTML.

Live Preview

Change the numbering type and see how the same items look.

Order stays the same; only the marker style changes.

List
  1. Mix the dry ingredients
  2. Add eggs and milk
  3. Bake for 20 minutes

<ol type="1">

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Basic Ordered List

Steps where order matters — a classic recipe list.

HTML
<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>
Try It Yourself

How It Works

  1. Open with <ol> because the sequence matters.
  2. Wrap each step in <li>…</li>.
  3. Browsers number items automatically (1, 2, 3… by default).
  4. Close with </ol> after the last item.

Example 2 — Letter / Roman Markers

Set type when the marker style itself carries meaning.

HTML
<ol type="i">
  <li>Introduction</li>
  <li>List of Grievances</li>
  <li>Conclusion</li>
</ol>
Try It Yourself

How It Works

  1. Add type="i" for lowercase Roman numerals.
  2. Other values: 1, a, A, I.
  3. Keep the same <li> items — only markers change.
  4. For pure styling, prefer CSS list-style-type instead.

Example 3 — start and reversed

Continue numbering from a value, or count down.

HTML
<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>
Try It Yourself

How It Works

  1. Set start="4" so the first item shows as 4 (then 5, 6…).
  2. start is always an Arabic integer, even with letter/Roman type.
  3. Add reversed (no value needed) to number high → low.
  4. 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>.

HTML
<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>
Try It Yourself

How It Works

  1. Keep top-level items as normal <li> children of <ol>.
  2. Open a nested <ol> (or <ul>) inside an <li>.
  3. Close the nested list, then close that parent <li>.
  4. 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.

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.

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.

Default CSS Settings

Typical user-agent defaults (exact values vary by browser):

default.css
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

The ol (ordered list) element marks a list where order matters — typically shown with numbers or letters. Put each item in an li element.
Use ol when changing the item order would change the meaning (recipes, steps, rankings). Use ul when order is not meaningful.
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.
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).
Place the nested ol or ul inside an li of the parent list — never as a direct child of another ol or ul.
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

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

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