Skip to content
Kuza Ndoto Academy

Lists

BeginnerChapter 2 · Page 10 of 253 min readUpdated 15 Nov 2026

Lists organise related items so they are easy to scan: shopping lists, steps in a recipe, navigation menus, glossaries. HTML has three kinds: unordered lists, ordered lists and description lists. Screen readers announce lists and how many items they contain, which helps users understand the content before they read it.

Unordered lists

Use <ul> when the order of items doesn't matter. Each item goes in an <li> (list item). Browsers show a bullet point before each item.

<h2>Things to pack for Naivasha</h2>
<ul>
  <li>Sweater (it gets cold at night)</li>
  <li>Sunscreen</li>
  <li>Phone charger</li>
</ul>

Ordered lists

Use <ol> when the sequence matters, such as instructions or rankings. Browsers number the items automatically, so you can add or remove items without renumbering by hand.

<h2>How to buy airtime with M-Pesa</h2>
<ol>
  <li>Open the M-Pesa menu.</li>
  <li>Choose "Buy Airtime".</li>
  <li>Enter the phone number and amount.</li>
  <li>Enter your PIN and confirm.</li>
</ol>

The browser shows the steps numbered 1, 2, 3, 4.

Ordered list attributes

AttributeEffectExample
startBegin counting at a different number<ol start="5"> numbers 5, 6, 7…
reversedCount downwards (a boolean attribute)a top-10 countdown: 10, 9, 8…
typeMarker style: 1, a, A, i or I<ol type="a"> gives a, b, c

Use type only when the marker style is part of the meaning, for example a legal document that refers to "clause (b)". For pure decoration, CSS's list-style-type property is the better tool. An individual <li> can also take a value attribute to set its own number.

Nested lists

A list can contain another list, but the inner list must go inside an <li>, not directly inside the outer <ul> or <ol>.

<ul>
  <li>Fruit
    <ul>
      <li>Mangoes</li>
      <li>Passion fruit</li>
    </ul>
  </li>
  <li>Vegetables</li>
</ul>
Common mistake

Placing the inner <ul> after </li>, directly inside the outer list. The only elements allowed as direct children of <ul> and <ol> are <li> (plus script-supporting elements). Anything else is invalid HTML and confuses screen readers about which item the sub-list belongs to.

Description lists

A <dl> holds groups of terms (<dt>) and their descriptions (<dd>). It suits glossaries, FAQs and name–value data such as product specifications.

<dl>
  <dt>SACCO</dt>
  <dd>Savings and Credit Co-operative: members save together and can borrow from the pool.</dd>
  <dt>Chama</dt>
  <dd>An informal group that saves and invests together.</dd>
</dl>

Browsers show each term on its own line and indent its description underneath. A term may have several descriptions, and several terms can share one description.

Lists for navigation

A site's main menu is a list of links, so developers usually mark it up as one. CSS can later turn the vertical bullets into a horizontal bar.

<nav>
  <ul>
    <li><a href="/">Home</a></li>
    <li><a href="projects.html">Projects</a></li>
    <li><a href="/contact">Contact</a></li>
  </ul>
</nav>

You'll learn about <nav> in Semantic HTML.

Try it

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Lists</title>
  </head>
  <body>
    <h1>Chapati night</h1>
    <h2>Ingredients</h2>
    <ul>
      <li>3 cups wheat flour</li>
      <li>1 cup warm water</li>
      <li>Oil
        <ul>
          <li>2 tablespoons for the dough</li>
          <li>a little for frying</li>
        </ul>
      </li>
      <li>A pinch of salt</li>
    </ul>
    <h2>Method</h2>
    <ol>
      <li>Mix the flour, salt and oil.</li>
      <li>Add water slowly and knead into a soft dough.</li>
      <li>Rest the dough for 30 minutes.</li>
      <li>Roll out and fry each chapati until golden.</li>
    </ol>
    <h2>Words to know</h2>
    <dl>
      <dt>Knead</dt>
      <dd>To press and fold dough until it is smooth.</dd>
    </dl>
  </body>
</html>

You'll see bulleted ingredients with a smaller indented sub-list under "Oil" (browsers use a hollow circle for second-level bullets), numbered steps 1 to 4, and the word "Knead" with its definition indented beneath it. Try adding reversed or start="10" to the <ol>.

Key points

  • <ul> is for items where order doesn't matter; <ol> is for sequences and is numbered automatically.
  • Every item is an <li>, and nested lists go inside an <li>.
  • <ol> supports start, reversed and type.
  • <dl> pairs terms (<dt>) with descriptions (<dd>); navigation menus are usually lists of links.
Up next · Text & ContentComments, Entities & SymbolsWrite comments and display reserved characters.
→

Tip: use the ← and → keys to move between pages.