Ordered lists help show items in a specific order. They make steps or rankings clear.
Ordered lists in HTML
Introduction
Syntax
HTML
<ol> <li>First item</li> <li>Second item</li> <li>Third item</li> </ol>
The <ol> tag creates the ordered list container.
Each item inside uses the <li> tag.
Examples
HTML
<ol> <li>Wake up</li> <li>Brush teeth</li> <li>Eat breakfast</li> </ol>
HTML
<ol type="A"> <li>Apple</li> <li>Banana</li> <li>Cherry</li> </ol>
HTML
<ol start="5"> <li>Step five</li> <li>Step six</li> </ol>
HTML
<ol reversed> <li>Last item</li> <li>Second last item</li> </ol>
Sample Program
This page shows an ordered list of morning routine steps. The list is numbered automatically by the browser.
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Morning Routine</title> <style> body { font-family: Arial, sans-serif; padding: 1rem; background-color: #f9f9f9; color: #333; } ol { background-color: #fff; padding: 1rem 2rem; border-radius: 0.5rem; max-width: 300px; box-shadow: 0 0 5px rgba(0,0,0,0.1); } li { margin-bottom: 0.5rem; } </style> </head> <body> <main> <h1>My Morning Routine</h1> <ol> <li>Wake up</li> <li>Brush teeth</li> <li>Eat breakfast</li> <li>Get dressed</li> <li>Leave for work</li> </ol> </main> </body> </html>
Important Notes
Ordered lists automatically number items, so you don't have to type numbers yourself.
You can change the numbering style with the type attribute (numbers, letters, roman numerals).
Remember to use semantic HTML for accessibility; screen readers announce the list and item numbers.
Summary
Use <ol> to create numbered lists.
Each list item goes inside <li> tags.
Ordered lists are great for steps, rankings, or anything where order matters.
Practice
1. What HTML tag is used to create a numbered list?
easy
Solution
Step 1: Understand list types in HTML
There are two main list types: ordered (<ol>) and unordered (<ul>).Step 2: Identify the tag for numbered lists
The<ol>tag creates numbered (ordered) lists, while<ul>creates bullet lists.Final Answer:
<ol> -> Option AQuick Check:
Numbered list tag = <ol> [OK]
Hint: Numbered lists always use <ol> tag [OK]
Common Mistakes:
- Confusing <ol> with <ul>
- Using <li> as the list container
- Trying to use a non-existent <list> tag
2. Which of the following is the correct syntax to start an ordered list in HTML?
easy
Solution
Step 1: Recall standard HTML tags for lists
The standard tag for ordered lists is<ol>. Other tags like<orderedlist>or attributes on<ul>are not valid HTML.Step 2: Confirm correct syntax
The correct way to start an ordered list is simply<ol>without extra attributes or incorrect tag names.Final Answer:
<ol> -> Option CQuick Check:
Correct ordered list tag = <ol> [OK]
Hint: Ordered lists start with <ol>, no extra attributes needed [OK]
Common Mistakes:
- Using non-standard tags like <orderedlist>
- Adding type attribute to <ul> for numbers
- Confusing <ul> and <ol> tags
3. What will be the visual output of this HTML code?
<ol> <li>First</li> <li>Second</li> <li>Third</li> </ol>
medium
Solution
Step 1: Understand the
The<ol>and<li>relationship<ol>tag creates a numbered list, and each<li>is a list item.Step 2: Predict the rendered output
The browser will show a numbered list: 1. First, 2. Second, 3. Third.Final Answer:
A numbered list with items: 1. First 2. Second 3. Third -> Option DQuick Check:
Ordered list with- items = numbered list [OK]
Hint: Ordered lists show numbers before each <li> item [OK]
Common Mistakes:
- Thinking <ol> creates bullets instead of numbers
- Expecting raw HTML code to show on page
- Believing <li> tags are invalid inside <ol>
4. Identify the error in this HTML snippet:
<ol> <li>Step 1</li> <li>Step 2</li> <li>Step 3</ol> </li>
medium
Solution
Step 1: Check tag nesting order
Each<li>must open and close inside the<ol>. Here, the last</li>is after</ol>, which breaks proper nesting.Step 2: Identify correct closing order
The last list item should close before the ordered list closes. The misplaced closing tag causes invalid HTML.Final Answer:
The closing </li> tag is misplaced after the closing </ol> tag -> Option AQuick Check:
List items must close before the list closes [OK]
Hint: Close all <li> tags before closing <ol> [OK]
Common Mistakes:
- Closing <li> after
- Mixing <ul> and <ol> tags incorrectly
- Forgetting to close <li> tags
5. You want to start an ordered list at number 5 instead of 1. Which attribute should you add to the
<ol> tag to do this?hard
Solution
Step 1: Recall the attribute to set starting number
Thestartattribute on<ol>sets the first number in the list.Step 2: Confirm correct attribute usage
Usingstart="5"will make the list begin numbering at 5.Final Answer:
start="5" -> Option BQuick Check:
Use start attribute to set list start number [OK]
Hint: Use start="number" on <ol> to begin numbering there [OK]
Common Mistakes:
- Using value or number attributes which don't exist on <ol>
- Trying to set start on <li> instead of <ol>
- Confusing with CSS counters
Recommended
Ready to prove it?
Pass the test and this pattern moves unknown
10 questions ~5 mineasy hard
