<ol> Tag in HTML
The <ol> tag in HTML is used to create an ordered (numbered) list. It is typically used when the sequence of list items is important, such as steps in a process or ranked items.
Key Points on <ol> Tag:
- The <ol> tag defines an ordered list.
- Each list item is defined by the <li> tag inside the <ol> tag.
- By default, items in an ordered list are numbered.
- The type attribute of the <ol> tag specifies the numbering style (e.g., numbers, letters, Roman numerals).
- The start attribute allows you to specify the starting number for the list.
- The reversed attribute reverses the order of the list numbering (e.g., descending order).
Syntax of <ol> Tag:
Syntax Example
<ol>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ol>
Example of <ol> Tag in HTML:
This example demonstrates how to create an ordered list using the <ol>
tag.
Code Example
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
Output
1.First item
2.Second item
3.Third item
Ordered List with Attributes:
In the following example, an ordered list is displayed with different types of numbering styles.
Code Example with Attributes
<ol type="A">
<li>Apple</li>
<li>Banana</li>
<li>Cherry</li>
</ol>
Output with Type "A" (Uppercase Letters)
A.Apple
B.Banana
C.Cherry
The <ol>
tag is useful for creating ordered lists, where the order of items is important. You can customize the appearance of the list with the type, start, and reversed attributes to fit your needs.