Lesson 23 of 51 · Module 4, lesson 2 of 6 · 3 min
Numbered lists
Make numbered lists for steps and rankings, and change how they count.
What you'll learn
- How to make a numbered list with
<ol>- How to start at another number, count down, or use letters
- When a list should be numbered
Why this matters
In a recipe, step 3 must come after step 2. When the order matters, a numbered list says so — to readers and to screen readers, which announce "list, 5 items" and read each number.
A numbered list
<ol> means ordered list. The items are <li>, as before. The browser adds the numbers for you.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tomato soup steps</title>
</head>
<body>
<h1>How to make tomato soup</h1>
<ol>
<li>Cut the tomatoes and the onion.</li>
<li>Cook them in water for twenty minutes.</li>
<li>Blend the soup.</li>
<li>Add salt to taste.</li>
</ol>
</body>
</html>
What you'll see: the steps numbered 1 to 4.
Add a step in the middle, and the numbers after it change by themselves. That is the big advantage over typing numbers.
Changing the numbers
| Attribute | What it does | Example |
|---|---|---|
start | Start at another number | <ol start="5"> counts 5, 6, 7… |
reversed | Count down (a boolean attribute) | <ol reversed> counts 4, 3, 2, 1 |
type | Letters or Roman numerals | type="A", type="a", type="I", type="i" |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Top dishes</title>
</head>
<body>
<h2>My top three dishes</h2>
<ol reversed>
<li>Fresh bread</li>
<li>Green salad</li>
<li>Tomato soup</li>
</ol>
<h2>Choose one answer</h2>
<ol type="A">
<li>Twenty minutes</li>
<li>One hour</li>
</ol>
</body>
</html>
Use type when the letters or numerals are part of the meaning — for example, answers A, B, C that a question refers to. If you only want a different look, that is a job for CSS.
Numbered lists inside lists
As with bulleted lists, an inner list goes inside an <li>. You can mix kinds: a numbered list of steps can hold a bulleted list of items.
Try it yourself
- Select the steps example and choose Try it.
- Add a new step between steps 1 and 2. Watch the numbers update.
- Add
start="10", then change it toreversed.
Common mistakes
- Typing the numbers yourself, as in
<li>1. Cut the tomatoes</li>. You get "1. 1. Cut…". Fix: let<ol>number the items. - Using
<ol>when the order does not matter. The numbers suggest an order that is not there. Fix: use<ul>. - Putting
startortypeon an<li>. They belong on the<ol>. Fix: move them.
Check yourself
- Which element makes a numbered list?
- How do you make a list start at 3?
- You add a step in the middle of an
<ol>. What happens to the numbers?
Answers
<ol>.<ol start="3">.- They update by themselves.
Next: the last kind of list pairs words with their explanations — like a glossary.


