← Back to all topics

HTML REFERENCE · 04

Lists

Lists express relationships between items. Choose the list type by whether order matters or whether you are pairing terms with descriptions.

Lists at a glance

Element or attribute What it means When to use it
ul An unordered list of related items. Use when rearranging the items would not change the meaning, such as a set of supplies.
ol An ordered list whose sequence matters. Use for steps, rankings, or other items with a meaningful order. Browsers normally display numbers.
li One item inside ul or ol. Wrap each list item in li. An item can contain text, paragraphs, or another list.
dl A description list containing groups of terms and descriptions. Use for a glossary or name–value information. It contains dt and dd rather than li.
dt A term or name within a description list. Use before the associated description, such as a vocabulary term or a feature name.
dd A description or value associated with a term. Use after its dt. One term can have more than one description.
start on ol An integer setting the first item’s ordinal value. Use when continuing a numbered sequence, such as start="4". It is not an attribute for ul.
reversed on ol A boolean attribute making an ordered list count downward. Use for a countdown or descending ranking. Its presence enables it; reversed="false" also enables it.
value on li An integer setting that ordered item’s ordinal value. Use inside ol to change the count at a particular item. Later items continue from that value.

Grouping items without an order

These supplies belong together, but their order does not matter. Bullets are the usual browser presentation; CSS can change the markers without changing the list’s meaning.

Code

<ul>
  <li>Notebook</li>
  <li>Pencil</li>
  <li>Water bottle</li>
</ul>

Output

  • Notebook
  • Pencil
  • Water bottle

Showing a meaningful sequence

The sequence below matters. Each step belongs in its own list item. Do not type the numbers into the text; the browser supplies the markers.

Code

<ol>
  <li>Open the document.</li>
  <li>Read the introduction.</li>
  <li>Review the notes.</li>
</ol>

Output

  1. Open the document.
  2. Read the introduction.
  3. Review the notes.

Nesting a list inside an item

The inner list belongs to “Writing supplies,” so it sits inside that li, before the closing tag. It is not a separate sibling placed between the outer items.

Code

<ul>
  <li>Writing supplies
    <ul>
      <li>Pencil</li>
      <li>Notebook</li>
    </ul>
  </li>
  <li>Water bottle</li>
</ul>

Output

  • Writing supplies
    • Pencil
    • Notebook
  • Water bottle

Pairing terms and descriptions

A description list connects each term with its explanation. It does not represent numbered steps or a set of bullet points.

Code

<dl>
  <dt>Trailhead</dt>
  <dd>The place where a trail begins.</dd>
  <dt>Ridge</dt>
  <dd>A long, narrow high point in the landscape.</dd>
</dl>

Output

Trailhead
The place where a trail begins.
Ridge
A long, narrow high point in the landscape.

Continuing or changing a count

Start changes the opening number. Value changes one item’s number and the sequence that follows it. Use these when the numbers carry meaning, rather than for visual decoration.

Code

<ol start="4">
  <li>Read the final section.</li>
  <li>Close the document.</li>
  <li value="8">Read the appendix.</li>
</ol>

Output

  1. Read the final section.
  2. Close the document.
  3. Read the appendix.

Counting downward

Reversed is enabled by its presence. Without a start value, a reversed list starts from its number of items. Here, start explicitly sets the opening number to three.

Code

<ol reversed start="3">
  <li>Third place: Pine</li>
  <li>Second place: Cedar</li>
  <li>First place: Oak</li>
</ol>

Output

  1. Third place: Pine
  2. Second place: Cedar
  3. First place: Oak

Further reading: W3Schools: Lists. The explanations and examples here are written for this guide.

Study questions

Answer in your own words before opening each explanation.

How do I choose between ul and ol?

Ask whether changing the order would change the meaning. Use ol for a meaningful sequence and ul for a group without a required order.

What does li represent?

One item within an unordered or ordered list. Each separate item gets its own li.

Where does a nested list belong?

Inside the parent item it expands, before that item’s closing li tag.

Does dl use li elements?

No. Use dt for terms and dd for their descriptions inside dl.

What is the difference between start and value?

Start sets the opening number of an ol. Value sets a particular li’s number within an ordered list.

Does reversed="false" switch reversing off?

No. Reversed is boolean, so any presence enables it. Remove the attribute to turn it off.

Should I type numbers into ordered-list items?

Usually no. The browser generates their markers. Typed numbers can become inconsistent when items are moved or added.

Does removing bullets with CSS remove list meaning?

The HTML elements still express a list, although how assistive technology exposes styled lists can vary. Choose the right elements first and check accessibility when changing their presentation.