Sub topic 9
Ordered, Unordered and Description Lists
This chapter assumes you can write a complete HTML document, you know what elements and attributes are, and you can mark up headings and paragraphs. It covers the three list types in HTML, how their content models work, and the mistakes that most often break them.
Why lists matter
A list is a group of related items. Browsers and assistive technology treat list markup as structure, not decoration. A screen reader can announce "list, 3 items" before reading the first item, so a user knows how much content to expect and can skip the whole list. Search engines and reader modes also use that structure.
HTML has three kinds of list:
| List | Element | Use it when |
|---|---|---|
| Unordered | `ul` | Items have no meaningful sequence |
| Ordered | `ol` | Order or count matters, such as steps or rankings |
| Description | `dl` | Items are name and value pairs, such as terms and definitions |
A useful test: if you could rearrange the items without changing the meaning, use ul. If rearranging would change the meaning, use ol.
Unordered lists
An unordered list is a ul element. Each item is an li (list item) element.
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>Browsers usually draw a bullet before each item. The bullet is a style choice made by the browser's default stylesheet, not part of the meaning. CSS can change or remove it, and the list is still a list to assistive technology.
The content model
The rules for what may go inside a list are strict:
- The only permitted direct children of
ulandolarelielements. Script-supporting elements (scriptandtemplate) are also allowed, but you will rarely need them here. - An
lican contain any flow content: text, paragraphs, links, images, or another list.
This means the following is invalid, because a p is a direct child of ul:
<ul>
<p>Shopping</p>
<li>Milk</li>
</ul>Put the heading or introduction before the list, not inside it.
Ordered lists
An ordered list is an ol element. It has the same li children, but browsers number the items by default.
<ol>
<li>Write the markup</li>
<li>Open it in a browser</li>
<li>Fix any problems you see</li>
</ol>Attributes of ol
Three attributes control the numbering:
startsets the number of the first item. It must be an integer, and it can be negative or zero.reversedis a boolean attribute that counts down instead of up.typesets the marker style:1(default),a,A,iorI.
<ol start="5">
<li>Fifth step</li>
<li>Sixth step</li>
</ol>
<ol reversed>
<li>Bronze</li>
<li>Silver</li>
<li>Gold</li>
</ol>The second list is numbered 3, 2, 1, so Gold is item 1. A boolean attribute is true when it is present, so you write reversed, not reversed="false". Writing reversed="false" still turns it on.
The li element also accepts a value attribute, which sets the number for that item. Later items continue counting from it.
<ol>
<li>Plan</li>
<li value="10">Build</li>
<li>Test</li>
</ol>This displays 1, 10, 11. Use value sparingly. It is mostly useful when a numbered list is split by other content and must continue.
Numbers come from the browser
The numbers are generated at render time. They are not in your text. If you type "1." inside an li, the page shows the number twice. Likewise, never replace a real list with paragraphs that begin with typed numbers, because the structure is lost.
Nested lists
A list can sit inside an li. The inner list must be inside the item, not between items.
<ul>
<li>Front end
<ul>
<li>HTML</li>
<li>CSS</li>
</ul>
</li>
<li>Back end</li>
</ul>The inner ul is a child of the first li. Placing it directly inside the outer ul would break the content model.
You can mix list types. An ol of steps can contain a ul of options for one step. Indent consistently so the nesting is easy to read.
Description lists
A description list is a dl element. It holds groups of terms and their descriptions. Two elements do the work:
dt(description term) is the name.dd(description details) is the value or definition.
<dl>
<dt>HTML</dt>
<dd>The language that describes the structure of a web page.</dd>
<dt>CSS</dt>
<dd>The language that describes how a page looks.</dd>
</dl>Description lists fit glossaries, metadata such as "Author: Ana", and question and answer pairs. They are not only for definitions.
One term, many descriptions, and the reverse
A term can have several descriptions, and several terms can share one description:
<dl>
<dt>Colour</dt>
<dt>Color</dt>
<dd>The visual property produced by different wavelengths of light.</dd>
<dt>Browser</dt>
<dd>A program that displays web pages.</dd>
<dd>Examples include Firefox, Chrome and Safari.</dd>
</dl>The first two dt elements share one dd. The last dt has two dd elements.
Grouping with div
In current HTML you may wrap each dt and dd group in a div. This helps with styling and keeps each group together. The div may contain only dt and dd elements.
<dl>
<div>
<dt>Author</dt>
<dd>Ana Pereira</dd>
</div>
<div>
<dt>Published</dt>
<dd>2026-11-30</dd>
</div>
</dl>No other wrapper is allowed. A dl must contain dt and dd groups, optionally inside div, and each group must start with at least one dt, followed by at least one dd.
Choosing the right list
Pick the list from the meaning of the content, not the look you want.
- A navigation menu is conventionally a
ulof links inside anavelement, because the links form a set. - A recipe's method is an
ol, because step order matters. - A recipe's ingredients are usually a
ul. - A contact card with labels and values suits a
dl.
Do not use lists only for indentation or spacing. If you want a visual effect, use CSS. Equally, do not avoid a list when your content really is one just because the default bullets look wrong. Keep the list and restyle it.
Common errors
| Mistake | Why it fails | Fix |
|---|---|---|
| `<p>` or text directly inside `ul` or `ol` | Only `li` is allowed as a child | Move the text into an `li` or place it before the list |
| Nested list placed between `li` elements | The inner list is not inside an item | Put the nested list inside the parent `li` |
| Typed numbers or dashes in items | Duplicates the generated markers and hides structure | Let the browser generate markers, and use CSS for style |
| `<li>` outside any list | An `li` needs a `ul` or `ol` parent | Wrap items in the correct list element |
| `dd` with no `dt` before it | A description needs a term | Add a `dt` first |
| `reversed="false"` | A boolean attribute is on if present | Remove the attribute |
Putting it together
This page uses all three list types and one nested list. It is a complete document you can save as lists.html and open in a browser.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Pancake Recipe</title>
</head>
<body>
<h1>Pancakes</h1>
<h2>Ingredients</h2>
<ul>
<li>200 g flour</li>
<li>2 eggs</li>
<li>300 ml milk
<ul>
<li>Any kind works</li>
</ul>
</li>
</ul>
<h2>Method</h2>
<ol>
<li>Whisk everything into a smooth batter.</li>
<li>Heat a lightly oiled pan.</li>
<li>Cook each side for about one minute.</li>
</ol>
<h2>Details</h2>
<dl>
<div>
<dt>Serves</dt>
<dd>4 people</dd>
</div>
<div>
<dt>Time</dt>
<dd>20 minutes</dd>
</div>
</dl>
</body>
</html>Open the page and check three things. The ingredients show bullets, the method shows 1 to 3, and the details show term and value pairs. Then open your browser's developer tools and inspect the elements to confirm the nesting matches what you wrote.
Exercise
A page has <ol><li>Mix</li><ul><li>Use a whisk</li></ul><li>Bake</li></ol>. What is wrong, and how do you fix it?
Show answer
The nested ul is a direct child of the ol, but only li elements may be direct children. Move the ul inside the first li: <ol><li>Mix<ul><li>Use a whisk</li></ul></li><li>Bake</li></ol>.
Exercise
Which list type fits a glossary of five terms with definitions, and which elements do you use for each part?
Show answer
A description list. Use dl for the list, dt for each term and dd for each definition. Optionally wrap each term and definition group in a div.
Exercise
You write <ol start="3" reversed><li>A</li><li>B</li><li>C</li></ol>. What numbers are shown?
Show answer
3, 2, 1. The list starts at 3 and counts down, so A is 3, B is 2 and C is 1.