Master HTML From Scratch

Clear, interactive, and structured HTML lessons designed for beginners.

HTML Ordered Lists

Ordered lists are used when the sequence or order of items is important. They display list items using numbers or other ordered markers.


1. What is an Ordered List?

An ordered list is created using the <ol> element. Each item inside the list is created using the <li> element.

<ol>
    <li>Step One</li>
    <li>Step Two</li>
    <li>Step Three</li>
</ol>
Output:
  1. Step One
  2. Step Two
  3. Step Three

2. The ol Element

The <ol> element defines the ordered list container.

<ol>

    <li>HTML</li>
    <li>CSS</li>
    <li>JavaScript</li>

</ol>

3. The li Element

The <li> element represents one item in an ordered list.

<ol>

    <li>Open the browser</li>
    <li>Create an HTML file</li>
    <li>Write HTML code</li>

</ol>
Output:
  1. Open the browser
  2. Create an HTML file
  3. Write HTML code

4. Default Numbering

By default, browsers display ordered list items using decimal numbers starting from 1.

<ol>
    <li>HTML</li>
    <li>CSS</li>
    <li>JavaScript</li>
</ol>
Default Result:
  1. HTML
  2. CSS
  3. JavaScript

5. Ordered List for Steps

Ordered lists are useful for instructions where the sequence matters.

<h2>How to Create an HTML File</h2>

<ol>
    <li>Open a text editor.</li>
    <li>Create a new file.</li>
    <li>Save the file with .html extension.</li>
    <li>Open the file in a browser.</li>
</ol>

6. type Attribute

The type attribute specifies the marker style used by the ordered list.

Type Marker Style Example
1 Decimal numbers 1, 2, 3
A Uppercase letters A, B, C
a Lowercase letters a, b, c
I Uppercase Roman numerals I, II, III
i Lowercase Roman numerals i, ii, iii

7. Decimal Numbering

<ol type="1">
    <li>HTML</li>
    <li>CSS</li>
    <li>JavaScript</li>
</ol>
  1. HTML
  2. CSS
  3. JavaScript

8. Uppercase Letters

Use type="A" for uppercase alphabetic markers.

<ol type="A">
    <li>HTML</li>
    <li>CSS</li>
    <li>JavaScript</li>
</ol>
  1. HTML
  2. CSS
  3. JavaScript

9. Lowercase Letters

<ol type="a">
    <li>HTML</li>
    <li>CSS</li>
    <li>JavaScript</li>
</ol>
  1. HTML
  2. CSS
  3. JavaScript

10. Uppercase Roman Numerals

<ol type="I">
    <li>Introduction</li>
    <li>Basic HTML</li>
    <li>Advanced HTML</li>
</ol>
  1. Introduction
  2. Basic HTML
  3. Advanced HTML

11. Lowercase Roman Numerals

<ol type="i">
    <li>Introduction</li>
    <li>Basic HTML</li>
    <li>Advanced HTML</li>
</ol>
  1. Introduction
  2. Basic HTML
  3. Advanced HTML

12. start Attribute

The start attribute specifies the starting number of an ordered list.

<ol start="5">
    <li>Item Five</li>
    <li>Item Six</li>
    <li>Item Seven</li>
</ol>
  1. Item Five
  2. Item Six
  3. Item Seven

13. Starting from a Different Letter

The start attribute works with other ordered list marker types as well.

<ol type="A" start="3">
    <li>Item One</li>
    <li>Item Two</li>
    <li>Item Three</li>
</ol>
  1. Item One
  2. Item Two
  3. Item Three

14. reversed Attribute

The reversed attribute displays an ordered list in descending order.

<ol reversed>
    <li>Step Three</li>
    <li>Step Two</li>
    <li>Step One</li>
</ol>
  1. Step Three
  2. Step Two
  3. Step One

15. reversed with start

The reversed and start attributes can be combined.

<ol reversed start="5">
    <li>First Item</li>
    <li>Second Item</li>
    <li>Third Item</li>
</ol>
  1. First Item
  2. Second Item
  3. Third Item

16. value Attribute on li

The value attribute on an <li> element can specify the marker value for that item.

<ol>

    <li value="10">Ten</li>
    <li>Eleven</li>
    <li>Twelve</li>

</ol>
  1. Ten
  2. Eleven
  3. Twelve

17. Ordered List with Links

List items can contain hyperlinks.

<ol>

    <li>
        <a href="html.html">Learn HTML</a>
    </li>

    <li>
        <a href="css.html">Learn CSS</a>
    </li>

    <li>
        <a href="javascript.html">Learn JavaScript</a>
    </li>

</ol>

18. Ordered List with Nested List

An ordered list can contain another list inside one of its items.

<ol>

    <li>
        Frontend

        <ul>
            <li>HTML</li>
            <li>CSS</li>
            <li>JavaScript</li>
        </ul>

    </li>

    <li>
        Backend

        <ul>
            <li>C#</li>
            <li>.NET</li>
            <li>SQL</li>
        </ul>

    </li>

</ol>
Output:
  1. Frontend
    • HTML
    • CSS
    • JavaScript
  2. Backend
    • C#
    • .NET
    • SQL

19. Multiple Nested Levels

Ordered lists can have several nested levels.

<ol>

    <li>
        Web Development

        <ol>

            <li>
                Frontend

                <ol>
                    <li>HTML</li>
                    <li>CSS</li>
                    <li>JavaScript</li>
                </ol>

            </li>

            <li>
                Backend

                <ol>
                    <li>C#</li>
                    <li>.NET</li>
                    <li>SQL</li>
                </ol>

            </li>

        </ol>

    </li>

</ol>

20. Ordered List for Tutorials

Ordered lists are useful for displaying learning steps.

<h2>Steps to Learn HTML</h2>

<ol>

    <li>Learn HTML syntax.</li>
    <li>Learn HTML elements.</li>
    <li>Learn HTML attributes.</li>
    <li>Practice forms and tables.</li>
    <li>Build a project.</li>

</ol>

21. Ordered List for a Process

<h2>Login Process</h2>

<ol>

    <li>Open the login page.</li>
    <li>Enter your username.</li>
    <li>Enter your password.</li>
    <li>Click the Login button.</li>
    <li>Access your dashboard.</li>

</ol>
Login Process
  1. Open the login page.
  2. Enter your username.
  3. Enter your password.
  4. Click the Login button.
  5. Access your dashboard.

22. Ordered List with CSS

CSS can be used to customize the appearance and spacing of ordered lists.

<style>

    .steps {
        padding-left: 25px;
        line-height: 1.8;
    }

</style>

<ol class="steps">

    <li>Create HTML file.</li>
    <li>Write HTML structure.</li>
    <li>Open the file in browser.</li>

</ol>

23. Ordered List with Custom Counter

CSS counters can be used to create custom numbering designs.

<style>

    .custom-list {
        counter-reset: step;
        list-style: none;
        padding: 0;
    }

    .custom-list li {
        counter-increment: step;
        margin-bottom: 10px;
    }

    .custom-list li::before {
        content: "Step " counter(step) ": ";
        font-weight: bold;
    }

</style>

<ol class="custom-list">

    <li>Learn HTML</li>
    <li>Learn CSS</li>
    <li>Learn JavaScript</li>

</ol>

24. Difference Between Ordered and Unordered Lists

Ordered List Unordered List
Uses <ol>. Uses <ul>.
Displays ordered markers. Displays bullets by default.
Useful when sequence matters. Useful when sequence does not matter.
Supports numbers, letters, and Roman numerals. Supports different bullet styles.

25. Common Mistakes

  • Using an ordered list when item order is not important.
  • Forgetting to place items inside <li>.
  • Using unnecessary nested ordered lists.
  • Using confusing numbering structures.
  • Using CSS only to visually number content that has no logical sequence.

26. Best Practices

  • Use <ol> when sequence or ranking matters.
  • Use <li> for each list item.
  • Use start only when a non-default starting value is required.
  • Use reversed when descending order is meaningful.
  • Use CSS for visual customization.
  • Keep nested lists logically organized.

27. Practice Task

Create an HTML page containing:

  1. An ordered list of learning steps.
  2. An ordered list using uppercase letters.
  3. An ordered list using lowercase letters.
  4. An ordered list using Roman numerals.
  5. An ordered list starting from number 5.
  6. A reversed ordered list.
  7. An ordered list containing a nested unordered list.
  8. An ordered list with hyperlinks.

28. Complete Practice Example

<!DOCTYPE html>
<html>

<head>

    <title>Ordered List Example</title>

    <style>

        .learning-steps {
            padding-left: 25px;
            line-height: 1.8;
        }

    </style>

</head>

<body>

    <h1>Steps to Become a Web Developer</h1>

    <ol class="learning-steps">

        <li>Learn HTML</li>
        <li>Learn CSS</li>
        <li>Learn JavaScript</li>
        <li>Learn a backend technology</li>
        <li>Learn SQL</li>
        <li>Build real projects</li>

    </ol>

    <h2>Frontend Topics</h2>

    <ol type="A">

        <li>HTML</li>
        <li>CSS</li>
        <li>JavaScript</li>

    </ol>

    <h2>Advanced Topics</h2>

    <ol type="I">

        <li>Accessibility</li>
        <li>SEO</li>
        <li>Performance</li>

    </ol>

</body>

</html>

Summary

Ordered lists are created using the <ol> element and contain <li> items. They are useful when the order of items matters, such as instructions, procedures, tutorials, rankings, and step-by-step processes. HTML supports different marker styles through the type attribute, while start, reversed, and value provide additional control over list numbering.