Content updated
By the end, you can…
- Choose a list type for a collection, sequence, or set of terms.
- Nest a list inside the item it belongs to.
One idea at a time
A list says that several pieces of information belong together. A shopping list is a collection; a recipe is a sequence. Their relationship matters more than whether you prefer bullets or numbers. Choosing the appropriate HTML gives browsers and assistive technology useful information about the group.
An unordered list uses ul and contains li elements. Use it when rearranging the items does not change their meaning. An ordered list uses ol with the same li elements, but their order matters. The browser generates the markers; you do not type a number at the start of each item.
A description list uses dl with dt for a term or name and dd for its description or value. It suits a small glossary or a set of facts. It does not use li. Start with a single term and description before adding more pairs.
Pair a term with its description: dl, dt, and dd
Sometimes a list is neither a collection of supplies nor a sequence of steps. A glossary pairs each word with its meaning. HTML calls this a description list. It can also pair names with values, such as a plant name and its watering needs.
Pair a term with its description. This list does not use li.
Remember the pair and its container
<dt>Term or name- The word being described, such as Seedling. Close dt before the description.
<dd>Description or value- Explains the preceding term, such as A young plant grown from a seed. It is a sibling of dt, not inside it.
<dl>Whole description list- Wraps the dt and dd pairs. Close dl after the final description.
<dl>
<dt>Seedling</dt>
<dd>A young plant grown from a seed.</dd>
<dt>Compost</dt>
<dd>Decomposed organic material.</dd>
</dl>Read the first pair as: Seedling means a young plant grown from a seed. The next dt starts another term, Compost, and the following dd describes it. In this simple example, each term has one description. dt and dd are siblings inside dl; do not place dd inside dt or wrap either in li.
Browsers usually indent descriptions beneath their terms. That appearance helps you see the pairs, but the relationship comes from the HTML, not the indentation. Use ul or ol with li for ordinary items; use dl with dt and dd when you need names paired with descriptions.
In the interactive example below, choose A term and its description. Match each visible term to its dt and each explanation to its dd. For your own glossary, add another dt followed by a dd before the closing dl tag.
Walk through an example
<h2>Supplies</h2>
<ul>
<li>Seeds</li>
<li>Soil</li>
</ul>
<h2>Planting steps</h2>
<ol>
<li>Fill the pot.</li>
<li>Plant the seeds.</li>
<li>Water gently.</li>
</ol>The supplies are an unordered collection, while the planting instructions depend on a sequence. Each list item opens and closes inside its own list. Add another planting step between the first two and the browser updates the numbers automatically. The headings name the groups but are outside the list containers.
See it happen: try a small change
Compare a collection with a sequence. Add a step by choosing the third version.
Code to notice
<h2>Supplies</h2>
<ul>
<li>Seeds</li>
<li>Soil</li>
</ul>Live result
What changed: The bullets group supplies without claiming one must come before another.
Keep nested information inside its parent item
A nested list adds detail to one item. If Tools contains a smaller list of Shovel and Watering can, put the inner ul before the closing li for Tools. Indentation makes that ownership visible in the source. A second list beside the item would not express the same parent-child relationship.
For an ordered list that continues an earlier sequence, start can set its first number. For example, <ol start="4"> begins its numbering at 4. Use that when the numbering itself conveys information. Leave decorative marker choices for CSS later. A list should remain meaningful even if its markers look different in another browser or stylesheet.
<ul>
<li>Tools
<ul>
<li>Shovel</li>
<li>Watering can</li>
</ul>
</li>
</ul>Try it in your browser
Put the list fragments inside body in your existing document. Save and refresh after adding one li. Check that the browser supplies the marker. For a nested list, find the outer item’s closing li in the editor and place the inner list before it.
A common wrong turn
A paragraph beginning with a dash only looks like a list item. It does not become an li. Similarly, placing an inner list after the closing parent li loses the intended nesting. Inspect the opening and closing tags rather than adding spaces to imitate the result.
Change one thing
Insert and remove one ordered item. Then compare a glossary with the same text in an unordered list. Explain what the term-description structure adds.
Your turn: organize a gardening checklist
Build a preparation page with three supplies, three ordered steps, and two gardening terms with descriptions. Add a small nested list of tools under one supply item.
Try this in your own HTML file, then open the page in a browser. There is no separate checked practice for this task yet.
- Write the information first and decide where order matters.
- Create the three list types inside your page body. For the glossary, put each term in dt and its explanation in dd, with both inside dl.
- Insert a step in the middle and check numbering. Check that the nested list stays inside its parent item.
Go to the source
Examples are authored for Tuklas and checked with code and reference documentation. This is not a claim of independent human review. Suggest a correction.