Skip to main content

HTML Lists and Tables

HTML Lists

Written by Updated HTML Lists exercises

HTML has three kinds of lists: ul for bullet points, ol for numbered steps, and dl for terms and their explanations. Choosing the right one is easy once you ask: does the order matter, or is it pairs of term and description?

Lists are not only for visible bullet points. Navigation menus, image galleries and product grids are often lists underneath, because they are a group of similar items.

Unordered List (<ul>)

The list is <ul>, and each item is an <li>. Use it when the order does not matter, like a list of features.

Unordered List Example

html

<ul>
  <li>HTML Basics</li>
  <li>CSS Styling</li>
  <li>JavaScript Introduction</li>
</ul>

Each item shows with a bullet point.

Ordered List (<ol>)

An <ol> numbers its items automatically. Use it when order matters, like steps in a process or a top-ten list.

Ordered List Example

html

<ol>
  <li>Register an account</li>
  <li>Verify your email</li>
  <li>Start learning HTML</li>
</ol>

The items are numbered 1, 2, 3. Add or remove one, and the numbers update themselves.

Changing the numbering

AttributeWhat it doesExample
typeThe numbering style: 1, A, a, I or i<ol type="A">
startThe number to start from<ol start="5">
reversedCounts down instead of up<ol reversed>

More details are in the ol tag.

Description List (<dl>)

A description list pairs terms with their explanations: <dl> is the list, <dt> each term and <dd> its description. Good for glossaries, FAQs and key-value details like product specifications.

Description List Example

html

<dl>
  <dt>HTML</dt>
  <dd>HyperText Markup Language used for web pages.</dd>

  <dt>CSS</dt>
  <dd>Cascading Style Sheets used for styling HTML.</dd>
</dl>

Each term appears on its own line, with its description indented underneath.

Nesting Lists

A list can go inside a list item, to show sub-points:

Nesting Lists Example

html

<ul>
  <li>Fruits
    <ul>
      <li>Apple</li>
      <li>Banana</li>
    </ul>
  </li>
  <li>Vegetables
    <ul>
      <li>Carrot</li>
      <li>Spinach</li>
    </ul>
  </li>
</ul>

The inner list goes inside the <li> it belongs to, before its closing </li>, not between two items.

Good to know

  • Only <li> can be a direct child of <ul> and <ol>. Text or other tags directly inside the list are invalid.
  • Change bullets and spacing with CSS, not by choosing a different tag; see CSS Lists.
  • Do not fake a list with line breaks. Screen readers announce real lists as "list, 3 items", which helps people know what is coming.

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesYes

HTML Lists exercises

A bullet list

Make a bullet list with the items Bread, Milk and Eggs.

Result

Check your answer to see it here.