Table of contents
1.
Introduction
2.
Syntax
3.
Steps to Create a Numbered List
3.1.
Step 1: Open Your HTML Document
3.2.
Step 2: Use the <ol> Tag to Start the List
3.3.
Step 3: Add List Items Using the <li> Tag
3.4.
Step 4: Save and View the Document in a Browser
3.5.
Example
4.
Customizing the Numbered List
4.1.
Changing the Start Number
4.2.
Changing the Numbering Style
4.3.
Example: Customizing List Style with CSS
5.
Frequently Asked Questions
5.1.
What is the difference between <ol> and <ul> in HTML?
5.2.
How can I change the numbering style in an ordered list?
5.3.
Can I skip numbers in a numbered list?
6.
Conclusion
Last Updated: Dec 26, 2024
Easy

How to Make a Numbered List in HTML

Author Pallavi singh
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Creating a numbered list in HTML is a simple yet essential task when you want to present ordered information on a web page. A numbered list helps organize content in a sequential order, making it easy to follow. 

How to Make a Numbered List in HTML

In this article, we will discuss how to create numbered lists using HTML, understand its syntax, and look at the steps involved in creating an ordered list. Whether you’re a beginner or someone brushing up on the basics, this article will help you create clear and structured content for your website.

Syntax

In HTML, a numbered list is created using the <ol> (ordered list) element. Each item in the list is enclosed in an <li> (list item) tag. Here’s the basic syntax to create a numbered list:

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


Explanation:

  • The <ol> tag defines the start of an ordered list.
     
  • The <li> tag is used to define each item within the list.
     
  • The browser automatically numbers each item within the <ol> tag, starting from 1 and continuing sequentially.
     

When this code is rendered in a browser, you will see the following output:

  1. First item
     
  2. Second item
     
  3. Third item

Steps to Create a Numbered List

Creating a numbered list in HTML is quite easy. Lets look at the steps:

Step 1: Open Your HTML Document

Before adding a numbered list, make sure you have an HTML document to work in. You can create a new HTML file using any text editor such as Notepad, VS Code, or Sublime Text.

Step 2: Use the <ol> Tag to Start the List

The <ol> tag is used to start the ordered list. It tells the browser that the items inside should be numbered.

<ol>
    <!-- List items will go here -->
</ol>

Step 3: Add List Items Using the <li> Tag

Each item within your list is placed inside the <li> tag. You can add as many <li> elements as you need, depending on how many items you want to include in your list.

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

Step 4: Save and View the Document in a Browser

Once you’ve added your list items, save the file with the .html extension (e.g., numbered-list.html). Open the file in a web browser (Google Chrome, Mozilla Firefox, etc.), and you will see the numbered list displayed.

Example

Here’s a full example of an HTML document with a numbered list:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Numbered List Example</title>
</head>
<body>
    <h1>How to Create a Numbered List in HTML</h1>
    <p>This is an example of a numbered list:</p>
    
    <ol>
        <li>Learn HTML Basics</li>
        <li>Practice Coding</li>
        <li>Build Projects</li>
    </ol>
</body>
</html>


Output:

Output

Customizing the Numbered List

You can also customize the look and style of the numbered list using CSS. For example, you can change the starting number, the type of numbering, or the indentation.

Changing the Start Number

By default, a numbered list starts at 1. If you want to start the list from a different number, you can use the start attribute within the <ol> tag.

<ol start="5">
    <li>Item 5</li>
    <li>Item 6</li>
</ol>


This will produce a list starting at 5:

  1. Item 5
     
  2. Item 6

Changing the Numbering Style

You can also change the style of the numbers using the type attribute. The type attribute can have the following values:

  • 1 for decimal numbers (default)
     
  • A for uppercase letters
     
  • a for lowercase letters
     
  • I for uppercase Roman numerals
     
  • i for lowercase Roman numerals
     

Here’s an example using the type attribute:

<ol type="A">
    <li>Item A</li>
    <li>Item B</li>
</ol>


This would display:

A. Item A

B. Item B

Example: Customizing List Style with CSS

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Styled Numbered List</title>
    <style>
        ol {
            list-style-type: upper-roman;
            color: blue;
        }
    </style>
</head>
<body>
    <h1>Styled Numbered List</h1>
    
    <ol>
        <li>Item I</li>
        <li>Item II</li>
        <li>Item III</li>
    </ol>
</body>
</html>


Output

Output

Frequently Asked Questions

What is the difference between <ol> and <ul> in HTML?

The <ol> tag is used for ordered lists, which are numbered. The <ul> tag is used for unordered lists, where the list items are usually marked with bullet points.

How can I change the numbering style in an ordered list?

You can change the numbering style using the type attribute in the <ol> tag. For example, type="A" will display uppercase letters, and type="I" will display Roman numerals.

Can I skip numbers in a numbered list?

No, HTML doesn’t allow skipping numbers in an ordered list. However, you can start from a different number using the start attribute in the <ol> tag.

Conclusion

In this article, we have learned how to create a numbered list in HTML using the <ol> and <li> tags. We discussed the syntax and the steps to add list items. Additionally, we discussed how to customize the starting number and change the style of the numbering using the start and type attributes. 

You can also check out our other blogs on Code360.

Live masterclass