edubun
English
1 / 16

6 / 10 · Intro

Lists

A shopping list and a recipe are both lists, but only one of them breaks if you change the order. HTML has a different element for each.

Jump to the 11 practice questions

You will learn

  • Nest a list inside the item it belongs to

Before this: Images and alt text

1Explain

Unordered and ordered lists

If the order of the items does not matter, use an unordered list, <ul>. Browsers mark each item with a bullet. If the order does matter, as in the steps of a recipe or a ranking, use an ordered list, <ol>, and the browser numbers the items for you. In both cases every visible item is an <li>, a list item. HTML also allows <script> and <template> directly inside <ul> or <ol>, but they do not create list items.

Your code
<h2>You will need</h2>
<ul>
  <li>500 g flour</li>
  <li>10 g salt</li>
  <li>350 ml warm water</li>
</ul>

<h2>Method</h2>
<ol>
  <li>Mix everything in a bowl.</li>
  <li>Leave it covered for 12 hours.</li>
  <li>Shape and bake at 230 degrees for 40 minutes.</li>
</ol>
Preview

2Explore

Options for ol

<ol> has a few attributes. start="4" begins the count at 4, useful when a list continues after a paragraph. reversed counts down, for a top ten. type switches the marker to letters or Roman numerals: type="a", type="A", type="i" or type="I". A single item can also jump to a number with value, as in <li value="10">. How the bullets and numbers look (their shape, colour, or whether they show at all) is controlled by CSS.

The steps stay the same; only the numbering changes.

Tap a choice: the code and the preview change together.

Attribute
<ol>
  <li>Mix</li>
  <li>Knead</li>
  <li>Bake</li>
</ol>
Preview

3Problem

start="5" with three items

An ol has start="5" and 3 items. What number does the last item show?

Hint

Count 5, 6, …

Solution

Answer: 7

start sets the first number, so three items show 5, 6 and 7.

4Problem

A reversed list

A reversed ol has 10 items. What does the first item show?

Hint

reversed counts down to 1.

Solution

Answer: 10

It counts down from the number of items: 10, 9, ... 1.

5Problem

Roman numerals from three

<ol type="i" start="3">
  <li>Shape</li>
  <li>Proof</li>
</ol>

What marker appears before Shape?

Hint

type sets the kind of numbering, start sets where it begins.

Solution

Answer: iii

type="i" uses small Roman numerals and start="3" begins at three, so the markers are iii and iv. start is always written as an ordinary number.

6Explain

Lists inside lists

A list item can contain a whole list. Put the inner <ul> or <ol> inside the <li> it belongs to, after that item's text and before its closing tag. A common mistake is to place the inner list between two <li> elements, directly inside the outer list, which is not allowed. Nested lists are how sites build menus with submenus and how outlines show sub-points.

Your code
<ul>
  <li>Bread
    <ul>
      <li>Sourdough</li>
      <li>Rye</li>
    </ul>
  </li>
  <li>Cakes</li>
</ul>
Preview

7Problem

Where a nested list goes

Where does a nested list go?

Hint

It belongs to one item.

Solution

Answer: Inside the li it belongs to

A list placed directly inside ul, between items, is invalid.

8Problem

Items in the outer list

<ul>
  <li>Drinks
    <ul>
      <li>Tea</li>
      <li>Coffee</li>
    </ul>
  </li>
  <li>Cakes</li>
  <li>Pastries</li>
</ul>

How many items does the outer list have?

Hint

The inner list belongs to one item; its items are not counted in the outer list.

Solution

Answer: 3

Drinks, Cakes and Pastries: 3. Tea and Coffee are items of the inner list inside Drinks. A screen reader announces the outer list as a list of 3 items.

9Explain

Description lists

The third kind of list pairs terms with descriptions, like a glossary or a set of questions and answers. <dl> is the description list, <dt> holds a term, and <dd> holds its description. One term can have several descriptions, and several terms can share one. Browsers indent the descriptions by default.

Your code
<dl>
  <dt>Crumb</dt>
  <dd>The soft inside of a loaf.</dd>
  <dt>Crust</dt>
  <dd>The hard outside.</dd>
</dl>
Preview

10Problem

The word being explained

In a description list, which element holds the word that is explained?

Hint

t for term, d for description.

Solution

Answer: dt

dt holds the term and dd its description, both inside dl. li belongs to ul and ol.

11Explain

Which list to use

A quick way to choose between the two: imagine shuffling the items. If shuffling changes the meaning, as it would for the steps of a recipe or a top ten, the list is ordered and needs <ol>. If nothing changes, as with a packing list, use <ul>. Keep each item short and start items in the same grammatical way, so the list is easy to scan.

ElementUse it whenExample
ulThe order does not matterA shopping list
olThe order mattersThe steps of a recipe
dlEach item is a term with a descriptionA glossary

12Problem

Typed numbers

Why use a real list instead of typing 1. 2. 3.?

Hint

Think of a screen reader announcing the list.

Solution

Answer: Screen readers announce the list and its length, and numbers update themselves

Structure is information that software can use.

13Practice

Two kinds of list

Turn the packing list into a <ul> with 3 items, and the steps into an <ol> with 4 items (no typed numbers).

Checks
  • ul with 3 items
  • ol with 4 items
  • steps in order
Your code
<h2>Packing list</h2>
<p>Water bottle, rain jacket, map</p>

<h2>Before you leave</h2>
<p>1. Check the weather. 2. Charge your phone. 3. Tell someone your route. 4. Lock the door.</p>
Preview
Hint

Packing: order does not matter. Steps: order matters, and the browser numbers them.

A solution
<h2>Packing list</h2>
<ul>
  <li>Water bottle</li>
  <li>Rain jacket</li>
  <li>Map</li>
</ul>

<h2>Before you leave</h2>
<ol>
  <li>Check the weather.</li>
  <li>Charge your phone.</li>
  <li>Tell someone your route.</li>
  <li>Lock the door.</li>
</ol>

14Practice

A nested list and a glossary

Nest a list with Sourdough and Rye inside the Bread item. Then turn the two definitions into a <dl> with <dt> and <dd>.

Checks
  • nested list in an item
  • Sourdough and Rye
  • two terms (dt)
  • two descriptions (dd)
Your code
<ul>
  <li>Bread</li>
  <li>Cakes</li>
</ul>

<p>Crumb: the soft inside of a loaf.</p>
<p>Crust: the hard outside.</p>
Preview
Hint

The inner ul goes after the word Bread and before </li>.

A solution
<ul>
  <li>Bread
    <ul>
      <li>Sourdough</li>
      <li>Rye</li>
    </ul>
  </li>
  <li>Cakes</li>
</ul>

<dl>
  <dt>Crumb</dt>
  <dd>The soft inside of a loaf.</dd>
  <dt>Crust</dt>
  <dd>The hard outside.</dd>
</dl>

15Explain

Common mistakes

Mistake
<ul>
  <li>Bread</li>
  <ul><li>Rye</li></ul>
</ul>
Fixed
<ul>
  <li>Bread
    <ul><li>Rye</li></ul>
  </li>
</ul>

A list directly inside ul is not allowed. The inner list belongs inside the li of Bread.

16

Summary

  • ul when order does not matter, ol when it does; every item is an li.
  • Nested lists go inside an li.
  • dl, dt and dd pair terms with descriptions.

Next unitTables
Full text · The whole lesson as one text

Unordered and ordered lists

If the order of the items does not matter, use an unordered list, <ul>. Browsers mark each item with a bullet. If the order does matter, as in the steps of a recipe or a ranking, use an ordered list, <ol>, and the browser numbers the items for you. In both cases every visible item is an <li>, a list item. HTML also allows <script> and <template> directly inside <ul> or <ol>, but they do not create list items. Text and other elements go inside the items.

<h2>You will need</h2>
<ul>
  <li>500 g flour</li>
  <li>10 g salt</li>
  <li>350 ml warm water</li>
</ul>

<h2>Method</h2>
<ol>
  <li>Mix everything in a bowl.</li>
  <li>Leave it covered for 12 hours.</li>
  <li>Shape and bake at 230 degrees for 40 minutes.</li>
</ol>
Ingredients can be listed in any order; the steps cannot.

Why not type the numbers or dashes yourself? Because then the browser does not know there is a list. A screen reader announces a real list with its length, for example list, 3 items, so the listener knows how much is coming and can skip past it. When you insert a step into an <ol>, every number after it updates by itself; with typed numbers you would renumber by hand.

Options for ordered lists

<ol> has a few attributes. start="4" begins the count at 4, useful when a list continues after a paragraph. reversed counts down, for a top ten. type switches the marker to letters or Roman numerals: type="a", type="A", type="i" or type="I". A single item can also jump to a number with value, as in <li value="10">. How the bullets and numbers look (their shape, colour, or whether they show at all) is controlled by CSS.

Lists inside lists

A list item can contain a whole list. Put the inner <ul> or <ol> inside the <li> it belongs to, after that item's text and before its closing tag. A common mistake is to place the inner list between two <li> elements, directly inside the outer list, which is not allowed. Nested lists are how sites build menus with submenus and how outlines show sub-points.

<ul>
  <li>Bread
    <ul>
      <li>Sourdough</li>
      <li>Rye</li>
    </ul>
  </li>
  <li>Cakes</li>
</ul>
The inner list sits inside the Bread item, before its closing tag.

Description lists

The third kind of list pairs terms with descriptions, like a glossary or a set of questions and answers. <dl> is the description list, <dt> holds a term, and <dd> holds its description. One term can have several descriptions, and several terms can share one. Browsers indent the descriptions by default.

Lists show up in places you might not expect. The menu at the top of most sites is a <ul> of links inside a <nav>; CSS lays the items out in a row and hides the bullets. A row of product cards or a set of search results is often a list too. When you see a group of similar things, ask whether it is a list; the answer is usually yes.

A quick way to choose between the two: imagine shuffling the items. If shuffling changes the meaning, as it would for the steps of a recipe or a top ten, the list is ordered and needs <ol>. If nothing changes, as with a packing list, use <ul>. Keep each item short and start items in the same grammatical way, so the list is easy to scan.

Which list to use

ElementUse it whenExample
ulThe order does not matterA shopping list
olThe order mattersThe steps of a recipe
dlEach item is a term with a descriptionA glossary
Key points
  • ul when order does not matter, ol when it does; every item is an li.
  • Nested lists go inside an li.
  • dl, dt and dd pair terms with descriptions.

Practice questions from Lists on edubun

Embed this quiz

Free to embed. Please keep the credit line.

Sources for this course (9)
  • WHATWG, HTML Living Standard (html.spec.whatwg.org, checked 2026-10-17)
  • MDN Web Docs, Learn web development: Structuring content with HTML, and the HTML element reference (developer.mozilla.org/en-US/docs/Learn_web_development/Core/Structuring_content and developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements, checked 2026-10-17)
  • MDN, HTML images (alt text guidance, checked 2026-10-17)
  • W3C WAI, Images tutorial and alt decision tree (w3.org/WAI/tutorials/images/decision-tree, checked 2026-10-17)
  • CERN, A short history of the Web (home.cern/science/computing/the-birth-of-the-web/short-history-web/, checked 2026-10-17)
  • W3C and WHATWG memorandum of understanding, 28 May 2019 (w3.org/2019/04/WHATWG-W3C-MOU.html, checked 2026-10-17)
  • W3C, Using ARIA, first rule of ARIA use (w3.org/TR/using-aria/, checked 2026-10-17)
  • W3C Markup Validation Service (validator.w3.org, checked 2026-10-17)
  • MDN, Viewport meta element (checked 2026-10-17).

Checked: 2026-10-17