Coding Hubs School of AI – Best AI & Full Stack Courses in Delhi NCR | 100% Placement
Limited Offer: Get 50% OFF on AI & Full Stack Courses
📞 Call Now: +91 8448811540
Back to HTML Notes
Topic #502

Ordered List

The <ol> element creates a numbered list — used when the order of items genuinely matters to their meaning.

Syntax

<ol>
    <li>First item</li>
    <li>Second item</li>
</ol>

Basic Example

<h2>How to Enroll</h2>
<ol>
    <li>Choose a course</li>
    <li>Book a free demo class</li>
    <li>Complete your registration</li>
</ol>

Browser output: "1. Choose a course", "2. Book a free demo class", "3. Complete your registration" — numbers generated automatically by the browser, never typed manually.

How It Works

The browser numbers each <li> automatically, starting at 1 by default. Adding or removing an item automatically renumbers every item after it — one of the real advantages of using <ol> over manually typed numbers.

Important Attributes

AttributePurpose
startSets the starting number (e.g. start="5" begins counting at 5)
reversedCounts downward instead of upward
typeChanges the marker style — 1 (default), A, a, I, i

Real-World Example

<h2>Top 3 Reasons Students Choose CodingNow</h2>
<ol>
    <li>Live, mentor-led classes — not pre-recorded videos</li>
    <li>Real projects, not just quizzes</li>
    <li>Dedicated placement support</li>
</ol>

A ranked "top 3" list is a genuine <ol> use case — the numbering itself communicates something (rank), which a bulleted list wouldn't.

Comparison: ol vs ul

<ol><ul>
MarkerNumbers (or letters/roman numerals)Bullets
Order matters?Yes — the sequence is part of the meaningNo — items could be reordered with no meaning lost
ExampleRecipe steps, race results, installation instructionsFeature lists, ingredient lists, navigation links

Full breakdown: unordered-list.

Common Mistakes

  • Using <ol> for content where order genuinely doesn't matter, just because numbers "look official"
  • Manually typing "1.", "2.", "3." as plain text inside a <ul> instead of using a real <ol>

Best Practices

  • Reserve <ol> for genuinely sequential content — steps, rankings, instructions
  • Let the browser generate the numbers automatically rather than typing them by hand

Accessibility Considerations

Screen readers announce both the list's scope ("list, 3 items") and each item's position ("item 2 of 3"), giving sequential context that a plain paragraph or bulleted list can't provide.

SEO Considerations

Numbered steps in real <ol> markup are a strong candidate for "how to" featured snippets in search results.

Browser & Modern HTML Notes

The type attribute (for roman numerals, letters) is technically presentational and can also be achieved via CSS list-style-type — either approach is valid, though CSS is generally preferred for pure styling changes.

Mini Practice

  1. Write a 4-step ordered list explaining how to make tea or coffee.
  2. Build an ordered list that starts counting from 10 using the start attribute.

Related HTML Notes

Want to go beyond the notes?

Join Coding Hubs School of AI's HTML course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available
💬 Talk to Advisor
1
WhatsApp

Latest from Our Blog

Insights on AI, Data Science, Full Stack & Career

View All Articles →