Back to HTML Notes
Topic #133

Ordered List

By the end of this lesson, you will be able to create numbered lists using the <ol> element and understand when to use it instead of an unordered list.

What it is

An ordered list (<ol>) is a block-level HTML element used to represent a list of items where the sequence or ranking matters. Each item within the list is wrapped in an <li> (list item) tag. The browser automatically numbers these items sequentially (1, 2, 3...) unless styled otherwise via CSS.

Mental Model: Think of an ordered list as a recipe step-by-step guide or a top-ten chart. If swapping two items changes the meaning or validity of the content, you need an ordered list.

Related terms: Unordered List (<ul>), List Item (<li>), Nested Lists.

Why it matters

  • Semantic Meaning: It tells search engines and assistive technologies (like screen readers) that the order of information is critical.
  • Accessibility: Screen readers announce "List with X items" and read the number before each item, helping users track their position.
  • Readability: Visual numbering helps users follow complex instructions or processes without losing their place.
  • Structure: It provides a clear hierarchy for sequential data, such as steps in a tutorial or ranked results.

Syntax or steps

The basic structure requires an opening <ol> tag, one or more <li> tags inside, and a closing </ol> tag.

  1. Open the list with <ol>.
  2. Add each item inside <li> tags.
  3. Close the list with </ol>.

Example

<ol>
  <li>Preheat oven to 350°F.</li>
  <li>Mix flour and sugar.</li>
  <li>Bake for 20 minutes.</li>
</ol>

Part-by-part explanation:

  • <ol>: Starts the ordered list container.
  • <li>...</li>: Defines individual steps. The browser automatically adds "1.", "2.", and "3." before the text.
  • </ol>: Ends the list container.

Common mistakes

  • Using <ol> for non-sequential data: Do not use ordered lists for bullet points like features or ingredients if the order doesn't matter. Use <ul> instead.
  • Manually typing numbers: Never write <li>1. Step One</li>. Let the browser handle the numbering so it remains consistent if you add or remove items.
  • Missing <li> tags: Text directly inside <ol> without <li> wrappers may render incorrectly or fail accessibility checks.
  • Nesting errors: When creating sub-lists, ensure the inner <ol> or <ul> is placed inside the parent <li>, not after it.

When to use it

Choose between <ol> and <ul> based on whether the sequence is significant.

Feature Ordered List (<ol>) Unordered List (<ul>)
Sequence Importance Critical (Step 1 must come before Step 2) Irrelevant (Items are equal priority)
Visual Marker Numbers (1, 2, 3) or Letters (A, B, C) Bullets (•, ◦, ▪)
Best For Instructions, rankings, timelines Features, navigation menus, random facts

Practice

Guided Exercise: Create an ordered list containing three steps to make a cup of tea: boil water, steep tea bag, pour into cup.

Challenge: Modify your code to start the numbering at 5 instead of 1 using the start attribute (e.g., <ol start="5">). Verify the output shows 5, 6, 7.

Quick check

Question: You are listing the main ingredients for a salad. Does the order matter? Should you use <ol> or <ul>?

Answer: The order usually does not matter for ingredients. You should use <ul> (unordered list).

Summary

The <ol> element is essential for presenting sequential information clearly and accessibly. Always prefer semantic HTML over manual formatting to ensure your content works well across devices and assistive technologies.

Want to go beyond the notes?

Join Coding Now Tech Institute's HTML course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Ordered List – FAQs

Quick answers about learning Ordered List in HTML.

This free note from Coding Now Tech Institute explains Ordered List in HTML — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every HTML topic on Coding Now Tech Institute, including Ordered List, is 100% free with no signup required.
With focused practice, most students grasp Ordered List in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now