The HTML <ol> tag is used to create ordered lists in HTML. An ordered list displays a numbered sequence of items.
Here's the basic structure of the <ol> tag:
<ol>
<!-- list items -->
</ol>
To define the individual items within the ordered list, you use the <li> (list item) tag. Each <li> tag represents a separate item in the list.
Example usage:
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
In this example, an ordered list is created with three list items (<li> tags). When rendered in a web browser, the list items will be displayed with sequential numbers.
You can customize the appearance of the ordered list by applying CSS styles. For example, you can change the numbering style (decimal, roman numerals, letters), the position of the numbers (inside or outside the list item), or add custom markers.
Example usage with custom numbering style:
<ol type="I">
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
In this example, the type attribute is added to the <ol> tag with a value of "I" to change the numbering style to uppercase Roman numerals.
Ordered lists are useful for presenting information that requires a specific order or sequence, such as step-by-step instructions, rankings, procedures, and more. Use the <ol> tag when you want to display a numbered list of items in a logical order.