Skip to main content

HTML Ordered Lists

The <ol> tag defines an ordered list. An ordered list can be numbered or alphabetical.


Ordered HTML List

An ordered list starts with the <ol> tag, and each item starts with the <li> tag. By default the items are marked with numbers.

Example

A basic numbered list.

Prompt
A basic ordered list (ol) with three items: Coffee, Tea, Milk, numbered by default.
Output: complete HTML page

Ordered HTML List - The Type Attribute

The type attribute of <ol> sets the marker type: type="1" for numbers (the default), type="A" for uppercase letters, type="a" for lowercase letters, type="I" for uppercase Roman numerals, and type="i" for lowercase Roman numerals.

Numbers

Numbered with numbers.

Prompt
An ordered list with type="1" so items are numbered with numbers: Coffee, Tea, Milk.
Output: complete HTML page

Uppercase letters

Numbered with uppercase letters.

Prompt
An ordered list with type="A" so items are numbered with uppercase letters: Coffee, Tea, Milk.
Output: complete HTML page

Lowercase letters

Numbered with lowercase letters.

Prompt
An ordered list with type="a" so items are numbered with lowercase letters: Coffee, Tea, Milk.
Output: complete HTML page

Uppercase Roman numerals

Numbered with uppercase Roman numerals.

Prompt
An ordered list with type="I" so items are numbered with uppercase roman numerals: Coffee, Tea, Milk.
Output: complete HTML page

Lowercase Roman numerals

Numbered with lowercase Roman numerals.

Prompt
An ordered list with type="i" so items are numbered with lowercase roman numerals: Coffee, Tea, Milk.
Output: complete HTML page

Control List Counting

By default an ordered list starts counting from 1. To start from another number, use the start attribute.

Example

A list that starts counting from 50.

Prompt
An ordered list that starts counting from 50 using the start attribute, items Coffee, Tea, Milk.
Output: complete HTML page

Nested HTML Lists

Lists can be nested, meaning one list can go inside another.

Note: A list item (<li>) can hold a new list and other elements too, like images and links.

Example

An ordered list with a sub-list inside one item.

Prompt
A nested ordered list: Coffee, Tea (with a sub-list of Black tea and Green tea), and Milk.
Output: complete HTML page

Chapter Summary

To recap: use the <ol> element for an ordered list, the type attribute for the numbering style, and the <li> element for each item. Lists can be nested, and items can hold other elements.


HTML List Tags

The list-related tags are: <ul> (an unordered list), <ol> (an ordered list), <li> (a list item), <dl> (a description list), <dt> (a term), and <dd> (the description of the term).