HTML Ordered List (<ol>):
The HTML Ordered List (<ol>) element is used to create lists in which the order of items is significant. It is often employed when presenting information in a sequential or hierarchical manner. Here's a detailed guide on using the HTML Ordered List:
- Basic Syntax:
- The (<ol>) element is used to create an ordered list.
- List items within the ordered list are defined with the (<li>) (list item) element.
- First Item
- Second Item
- Third Item
- Type Attribute:
- The type attribute can be used to specify the type of numbering or markers used in the ordered list.
- Possible values include "1" (numbers), "A" (uppercase letters), "a" (lowercase letters), "I" (uppercase Roman numerals), and "i" (lowercase Roman numerals).
- Item A
- Item B
- Item C
- Start Attribute:
- Item 5
- Item 6
- Item 7
- Nested Ordered Lists:
- Ordered lists can be nested inside other list items to create a hierarchical structure.
- Main Item 1
- Sub-item A
- Sub-item B
- Main Item 2
<ol>
<li>First Item</li>
<li>Second Item</li>
<li>Third Item</li>
</ol>
Output:-
<ol type="A"> <li>Item A</li> <li>Item B</li> <li>Item C</li> </ol>
Output:-
<ol start="5">
<li>Item 5</li>
<li>Item 6</li>
<li>Item 7</li>
</ol>
Output:-
<ol> <li>Main Item 1 <ol> <li>Sub-item A</li> <li>Sub-item B</li> </ol> </li> <li>Main Item 2</li> </ol>
Output:-
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Ordered List Example</title> </head> <body> <h1>Numbered List Example</h1> <ol type="I"> <li>Item I</li> <li>Item II</li> <li>Item III</li> </ol> </body> </html>Output:-
Numbered List Example
- Item I
- Item II
- Item III