📋 Ordered, Unordered, and Definition Lists
Lists are how the web organizes anything that comes in groups — navigation menus, recipe steps, glossaries, feature bullets. This lesson covers HTML's three list types, how to nest them, the attributes that control numbering, and how to style their markers with modern CSS.
🎯 Learning Objectives
By the end of this lesson, you will be able to:
- Choose the right list type — unordered, ordered, or definition — for a given piece of content
- Write correct
<ul>,<ol>, and<dl>markup, including nested lists - Control ordered-list numbering with the
type,start, andreversedattributes - Style list markers with
list-style-*and the::markerpseudo-element - Explain how lists improve accessibility for screen-reader users
Estimated Time: 25–35 minutes • Difficulty: Beginner
Hands-on: Build a recipe page that uses all three list types together.
In This Lesson
Three Kinds of List
Whenever information naturally comes as a group of items, a list is the semantically correct container. HTML gives you three, and the right choice depends on one question: does the order matter, and is each item a pair?
Every list type shares the same core idea: a container element wraps a series of items. For <ul> and <ol>, each item is a <li>. For <dl>, items come in pairs of <dt> (term) and <dd> (description).
📖 Key Terms
<ul>: unordered list — a bulleted collection where sequence is irrelevant.
<ol>: ordered list — a numbered sequence where position carries meaning.
<dl>: description (definition) list — term/description pairs.
Unordered Lists
Reach for an unordered list when the items form a set but no particular order is implied. The browser renders each <li> with a bullet.
<ul>
<li>Whole-wheat flour</li>
<li>Active dry yeast</li>
<li>Sea salt</li>
</ul>
Renders as:
- Whole-wheat flour
- Active dry yeast
- Sea salt
Unordered lists are everywhere: navigation menus, feature bullets on a product page, recipe ingredients, tags on a blog post, and items in a shopping cart. Anytime you would write bullet points in a document, this is the element.
💡 Navigation is a list
It surprises newcomers, but a site's nav bar is almost always an unordered list of links wrapped in a <nav>. It is a group of links with no inherent order, and marking it up as a real list means screen readers announce "list, 5 items" and users can navigate it predictably. CSS then turns it horizontal.
Ordered Lists
Use an ordered list when sequence matters — step-by-step instructions, rankings, or numbered clauses. The browser numbers the items for you, so you never hard-code "1.", "2.", "3." into the text.
<ol>
<li>Mix the dry ingredients.</li>
<li>Add milk, eggs, and melted butter.</li>
<li>Whisk until just smooth.</li>
</ol>
Renders as:
- Mix the dry ingredients.
- Add milk, eggs, and melted butter.
- Whisk until just smooth.
Controlling the numbering
Three attributes shape how an ordered list counts:
| Attribute | Effect | Example |
|---|---|---|
type | Marker style: 1, A, a, I, i | <ol type="A"> → A, B, C |
start | Starting number | <ol start="5"> → 5, 6, 7 |
reversed | Counts down instead of up | <ol reversed> → 3, 2, 1 |
<!-- A top-3 countdown, rendered with Roman numerals starting high -->
<ol type="I" reversed>
<li>Bronze medal</li>
<li>Silver medal</li>
<li>Gold medal</li>
</ol>
⚠️ Style vs. semantics for markers
The type attribute changes the meaning-bearing marker (e.g. legal sub-clauses labeled A, B, C). For purely visual marker changes, prefer the CSS list-style-type property instead, keeping presentation in your stylesheet.
Nesting Lists
Lists can contain other lists, letting you represent hierarchy — sitemaps, multi-level menus, outlines. The key rule: a nested list goes inside the <li> it belongs to, not between list items.
<ul>
<li>Home</li>
<li>Products
<ul>
<li>Category A
<ul>
<li>Product A1</li>
<li>Product A2</li>
</ul>
</li>
<li>Category B</li>
</ul>
</li>
<li>Contact</li>
</ul>
Renders as:
- Home
- Products
- Category A
- Product A1
- Product A2
- Category B
- Category A
- Contact
You can freely mix types — an ordered list can hold an unordered sub-list, and vice versa. A tutorial's numbered steps might each carry a bulleted list of tips.
<ul> lives inside its parent <li>, producing a tree that assistive tech can announce level by level.Definition Lists
The definition (description) list, <dl>, pairs terms with descriptions. Each term is a <dt> and each description a <dd>. It is the semantically correct choice for glossaries, FAQs, metadata, and specification tables.
<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language — the structure of a page.</dd>
<dt>CSS</dt>
<dd>Cascading Style Sheets — the presentation of a page.</dd>
</dl>
Renders as:
- HTML
- HyperText Markup Language — the structure of a page.
- CSS
- Cascading Style Sheets — the presentation of a page.
The pairing is flexible. One term can take multiple descriptions (several consecutive <dd>s), and multiple terms can share one description (several consecutive <dt>s):
<dl>
<dt>Storage</dt>
<dd>128 GB</dd>
<dd>256 GB</dd>
<dd>512 GB</dd>
<dt>HTML</dt>
<dt>HyperText Markup Language</dt>
<dd>The standard markup language for web pages.</dd>
</dl>
💡 Underused, but perfect for the job
Definition lists are far less common than <ul> and <ol>, but when your content genuinely is term/description pairs, <dl> communicates that relationship to assistive tech in a way a plain <ul> cannot.
Styling & Accessibility
Marker styling with CSS
Keep structure in HTML and appearance in CSS. The list-style-type property changes the marker, list-style-position sets inside/outside, and the modern ::marker pseudo-element styles the bullet or number directly.
/* Turn a nav list horizontal and strip its bullets */
.nav {
list-style: none;
margin: 0;
padding: 0;
display: flex;
gap: 1rem;
}
/* Color just the markers, not the text */
li::marker {
color: var(--primary-color, #3b82f6);
font-weight: 700;
}
For advanced numbering — "Chapter 1", "1.2", and the like — CSS counters give you full control while the HTML stays a clean <ol>:
ol.chapters {
counter-reset: chapter;
list-style: none;
}
ol.chapters > li {
counter-increment: chapter;
}
ol.chapters > li::before {
content: "Chapter " counter(chapter) ": ";
font-weight: 700;
}
Why the semantics matter for accessibility
When a screen reader meets a real list, it announces useful context — "list, 3 items" — and reads each item with its position. That context vanishes if you fake a list with <div>s and CSS bullets. Nested lists are announced level by level, so proper nesting communicates hierarchy to users who can't see the indentation.
✅ The payoff
Marking navigation, steps, and glossaries as true lists is one of those "free" wins: no extra work beyond choosing the right element, and every screen-reader user benefits immediately.
Hands-on Exercise
🏋️ Build a Recipe Page with All Three Lists
Objective: Use each list type where it fits best on one page.
Instructions:
- Add an unordered list of ingredients (order doesn't matter).
- Add an ordered list of preparation steps (order matters).
- Add a definition list for the nutrition facts (term/value pairs).
- Bonus: nest a short unordered list of tips inside one of the steps.
💡 Hint
Ask the deciding question for each block. Ingredients are a set → <ul>. Steps are a sequence → <ol>. "Calories: 210" is a term and a value → <dl> with <dt>/<dd>.
✅ Solution
<h1>Chocolate Chip Cookies</h1>
<h2>Ingredients</h2>
<ul>
<li>225 g butter, softened</li>
<li>200 g brown sugar</li>
<li>300 g plain flour</li>
<li>200 g chocolate chips</li>
</ul>
<h2>Instructions</h2>
<ol>
<li>Cream the butter and sugar until fluffy.
<ul>
<li>Tip: room-temperature butter creams best.</li>
</ul>
</li>
<li>Beat in the egg and vanilla.</li>
<li>Fold in flour, then the chocolate chips.</li>
<li>Bake at 180°C for 11–13 minutes.</li>
</ol>
<h2>Nutrition (per cookie)</h2>
<dl>
<dt>Calories</dt>
<dd>210 kcal</dd>
<dt>Sugar</dt>
<dd>18 g</dd>
</dl>
Each list type now carries the correct meaning, and the page reads cleanly to both browsers and assistive technology.
Best Practices
| ✅ Do | 🚫 Don't |
|---|---|
| Pick the list type by meaning (sequence? pairs?) | Use <ul> for everything out of habit |
Put a nested list inside its parent <li> | Place a <ul> as a direct sibling between <li>s |
Let <ol> generate the numbers | Type "1.", "2." into the item text |
Style markers with CSS list-style / ::marker | Rebuild bullets from <div>s and lose the semantics |
Use <dl> for true term/description pairs | Force glossary content into a two-column table |
🎯 Quick Quiz
Question 1: You're marking up the steps to assemble a bookshelf, where the order is essential. Which element is correct?
Question 2: Which attribute makes an ordered list begin counting at 5?
Question 3: What is the correct place for a nested list?
Summary & Quiz
🎉 Key Takeaways
- Unordered lists (
<ul>) group items where order is irrelevant. - Ordered lists (
<ol>) number a sequence;type,start, andreversedtune the counting. - Definition lists (
<dl>) pair<dt>terms with<dd>descriptions. - Nested lists go inside the parent
<li>and can mix types. - Style markers with CSS; the semantic list gives screen readers item counts and hierarchy for free.
📚 Further Reading
🚀 What's Next?
You can now structure content into blocks and lists. Next we zoom in on the inline level: the elements that add meaning and style to runs of text within those blocks — emphasis, code, quotations, abbreviations, and more.
🎉 Nicely organized!
Your content has structure and grouping. Let's polish the words themselves next.