The <ol> HTML element is used to create ordered lists.
For example
- First item
- Second item
- Third item
There are two useful attributes to make the most of ordered list.
Start attribute
The start attribute is used to specify the starting number of the list.
To use the start attribute, simply add the start attribute to the element and set its value to the desired starting number.
For example:
<ol start="4"> <li>List item 1</li> <li>List item 2</li> <li>List item 3</li> </ol>
This will create an ordered list that starts at 4, like this:
- First item
- Second item
- Third item
Reversed attribute
The reversed attribute is used to create a list in reversed order.
To create a reversed order list, simply add the reversed attribute to the element.
For example:
<ol reversed> <li>First item</li> <li>Second item</li> <li>Third item</li> </ol>
This will create a reversed ordered list that looks like this:
- First item
- Second item
- Third item
Using start and reversed attributes together
You can also combine the start and reversed attributes to create a reversed ordered list that starts at a specific number.
For example:
<ol start="4" reversed> <li>First item</li> <li>Second item</li> <li>Third item</li> </ol>
This will create a reversed ordered list that starts at 4 and looks like this:
- First item
- Second item
- Third item