HTML <ol> Tag
HTML <ol> tag is used to create an ordered list, which contains elements in a certain sequence.
Each element of the ordered list starts with the opening <li> tag and ends with the closing tag </li>. In addition to the text, the <li> tag may include other HTML elements (lists, images, headings, paragraphs, etc.).
In general, ordered list items have a preceding marker, such as a letter or number.
The following values can be used as numbering elements: Arabic numbers (1, 2, 3, ...); uppercase Latin letters (A, B, C, ...); lowercase latin letters (a, b, c, ...); Roman capital numbers (I, II, III, ...); Roman lowercase numbers (i, ii, iii, ...). The type attribute is used to indicate the type of the numbered list.
If you do not specify any additional attribute, then the content of the <ol> tag is by default numbered with Arabic numbers, starting with one.
Both the <ol> and <ul> tags represent a list of items. However, there is a difference with the <ol> tag where the order is meaningful.
Normally, the <ol> and <ul> tags can nest as deeply as required, alternating between them as you want.
TIP
If the CSS properties are applied to the <ol> tag, then the elements nested in the <li> tag inherit them.
Syntax
The <ol> tag comes in pairs. The content is written between the opening (<ol>) and closing (</ol>) tags.
Example of the HTML <ol> tag:
Example of the ordered list with HTML <ol> Tag
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<ol>
<li>Appetizers</li>
<li>Hot</li>
<li>Salads</li>
</ol>
<ol start="50">
<li>Cold drinks</li>
<li>Hot drinks</li>
<li>Ice-Cream</li>
</ol>
<ol type="A">
<li>Coca-Cola</li>
<li>Ice Tea</li>
<li>Fanta</li>
</ol>
</body>
</html>In the given example, we used the start attribute with the value "50".
To determine the type of numbering elements instead of the type attribute, use the CSS list-style-type property.
Example of the HTML <ol> tag used with the CSS list-style-type property:
Example of the HTML <ol> Tag with a list-style-type property
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<h2>Examples of ordered lists</h2>
<ol style="list-style-type: upper-roman">
<li>Cold drinks</li>
<li>Hot drinks</li>
<li>Ice-Cream</li>
</ol>
<ol style="list-style-type: hebrew">
<li>Coca-Cola</li>
<li>Fanta</li>
<li>Ice Tea</li>
</ol>
<ol style="list-style-type: decimal">
<li>Coca-Cola</li>
<li>Fanta</li>
<li>Ice Tea</li>
</ol>
</body>
</html>Result

Attributes
| Attribute | Value | Description |
|---|---|---|
| compact | compact | Reduces indents and spacing between lines. Not supported in HTML5. Instead, we recommend to use the CSS line-height property. |
| reversed | reversed | Indicates, that the list elements should be in the descending order (instead of the usual ascending order). |
| start | number | Sets the number from which the ordered list begins. The value must be an integer, negative values may be used. When used with letters (type = "A" and type = "a"), the number indicated in the attribute value corresponds to the ordinal number of the letter in the alphabet. For example, start = "5", will correspond to the letter "E" and the list will begin with it. If start = "27" is specified, the list becomes two-digit ("27" = "AA", "28" = "AB", "29" = "AC" ...). |
| type | 1 A a I i | Defines the type of the list marker. |
The <ol> tag supports the Global Attributes and the Event Attributes.
How to style an HTML <ol> Tag
{
"tag_name": "ol"
}Practice
What are the features and uses of the HTML <ol> tag?