<ol>

The HTML <ol> element generates a numbered list, where each item (<li>) appears in a defined sequence, often used for content that follows a particular order.

<ol> Tag

The <ol> element in HTML is used to create an ordered list, where items are automatically numbered in sequence by the browser.

Syntax

index.html
<ol>
  <li>First item</li>
  <li>Second item</li>
  <li>Third item</li>
</ol>

<ol> Demo

  1. Introduction
  2. Development
  3. Conclusion
index.html
<ol>
  <li>Introduction</li>
  <li>Development</li>
  <li>Conclusion</li>
</ol>

Ordered List - type Attribute

The type attribute allows you to define different numbering formats for list items:

TypeDescription
type="1"Numbers (default)
type="A"Uppercase letters
type="a"Lowercase letters
type="I"Uppercase Roman numerals
type="i"Lowercase Roman numerals

Examples

Numbered List

  1. Coffee
  2. Tea
  3. Milk
index.html
<ol type="1">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>

Uppercase Letters

  1. Coffee
  2. Tea
  3. Milk
index.html
<ol type="A">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>

Lowercase Letters

  1. Coffee
  2. Tea
  3. Milk
index.html
<ol type="a">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>

Roman Numbers - Uppercase

  1. Coffee
  2. Tea
  3. Milk
index.html
<ol type="I">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>

Roman Numbers - Lowercase

  1. Coffee
  2. Tea
  3. Milk
index.html
<ol type="i">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>
A <li> item can contain text, nested lists, images, links, and other HTML elements.

Attributes

  • reversed – Displays items in descending order.
  • start – Specifies the starting number.
  • type – Defines the numbering format (1, A, a, I, i).
TagDescription
<ul>Creates an unordered list
<ol>Creates an ordered list
<li>Defines an item in a list
<dl>Defines a description list
<dt>Specifies a term in a description list
<dd>Provides a description of a term

See Also

  • Other List Elements: <ul>, <li>, <menu>
  • CSS Styling Options:
    • list-style – Customizes numbering.
    • counter – Manages nested lists.
    • margin – Controls list indentation.

Conclusion

The <ol> tag in HTML is a versatile tool for creating ordered lists, allowing content to be presented in a sequential format. It offers customization options through attributes like type, start, and reversed to change the numbering style and order. By utilizing nested lists, developers can create complex structures within the list items.