Simple Tutorials for Smart Learning
An ordered list in HTML is a list of items displayed in a specific sequence using numbers or letters.
✅ Use Cases:✔ Numbering steps in a tutorial or guide✔ Ranking items (e.g., Top 10 lists)✔ Creating outlines and to-do lists
The <ol> tag creates an ordered list, and each item is wrapped in <li> (list item) tags.
<ol>
<li>
✅ Example:
<ol> <li>Wake up</li> <li>Brush teeth</li> <li>Eat breakfast</li> </ol>
✅ Output:
You can change the numbering style using the type attribute or CSS.
type
<ol type="A"> <li>First</li> <li>Second</li> <li>Third</li> </ol>
✅ Output:A. FirstB. SecondC. Third
✔ Available type values:
"1"
"A"
"a"
"I"
"i"
You can create multi-level lists by nesting <ol> inside <li>.
<ol> <li>Morning Routine <ol type="a"> <li>Wake up</li> <li>Shower</li> </ol> </li> <li>Work Tasks <ol type="i"> <li>Check emails</li> <li>Attend meetings</li> </ol> </li> </ol>
Use reversed to display the list in descending order.
reversed
<ol reversed> <li>Complete project</li> <li>Submit report</li> <li>Get approval</li> </ol>
✅ Output:3. Complete project2. Submit report
list-style-type
Instead of using the type attribute, CSS provides more control over styles.
<ol style="list-style-type: lower-roman;"> <li>Item One</li> <li>Item Two</li> </ol>
✅ Output:i. Item Oneii. Item Two
✔ Other list-style-type values:
decimal
decimal-leading-zero
lower-greek
✔ Use ordered lists for steps and rankings.✔ Avoid using <ol> for unordered data.✔ Keep list items short and clear.✔ Use CSS for styling rather than deprecated attributes.