Log inSign up free
Getting Started, HTML
  1. Getting started

    1. Lesson 1: What Is HTML?
    2. Lesson 2: HTML Document Structure
    3. Lesson 3: HTML Tags
    4. Lesson 4: HTML Links
    5. Lesson 5: HTML Images
    6. Lesson 6: HTML Lists
    7. Lesson 7: HTML Tables
    8. Lesson 8: HTML Forms
    9. Lesson 9: Semantic HTML
Getting Started, HTML

Getting started · Lesson 6 of 9 · 3 min read · By Jack

Lesson 6: HTML Lists

By the end, you'll know how to create unordered, ordered and description lists, nest them, and use lists to build navigation menus.

Estimated time: 20 minutes (about 8 minutes reading, 12 minutes practice)

Learning goals: By the end, you'll know how to create unordered, ordered and description lists, nest them, and use lists to build navigation menus.

Why lists?
Lists group related items so they're easier to scan. Menus, steps, ingredients and product features are all lists. HTML has three types.


Part 1: Unordered lists (3 min)

Use <ul> when the order doesn't matter. Each item goes in an <li> (list item). Browsers show bullet points by default.

<ul>  
  <li>Apples</li>  
  <li>Bread</li>  
  <li>Milk</li>  
</ul>
  • <ul> stands for unordered list.
  • <li> stands for list item.
  • Only <li> elements should sit directly inside <ul>.

Part 2: Ordered lists (4 min)

Use <ol> when the order matters, such as steps or rankings. Browsers number the items automatically.

<ol>  
  <li>Boil the water</li>  
  <li>Add the pasta</li>  
  <li>Cook for 10 minutes</li>  
</ol>

Useful attributes:

AttributeExampleEffect
start<ol start="5">Starts counting at 5
reversed<ol reversed>Counts down
type<ol type="A">Uses letters (A, B, C) or Roman numerals (I, i)
<ol type="A" start="3">  
  <li>Third item, shown as C</li>  
  <li>Fourth item, shown as D</li>  
</ol>

Part 3: Nested lists (3 min)

Place a new list inside an <li>, not directly inside the <ul> or <ol>.

<ul>  
  <li>Fruit  
    <ul>  
      <li>Apples</li>  
      <li>Bananas</li>  
    </ul>  
  </li>  
  <li>Vegetables  
    <ul>  
      <li>Carrots</li>  
      <li>Peas</li>  
    </ul>  
  </li>  
</ul>

Indent each level so you can see the structure. You can mix types, for example an <ol> inside a <ul>.

Part 4: Description lists (2 min)

Use <dl> for terms and their definitions, like a glossary.

<dl>  
  <dt>HTML</dt>  
  <dd>The language that structures web pages.</dd>  
  
  <dt>CSS</dt>  
  <dd>The language that styles web pages.</dd>  
</dl>
  • <dl> is the description list.
  • <dt> is the term.
  • <dd> is the description.

Part 5: Lists for navigation (3 min)

Most website menus are lists of links. This is standard practice and helps screen readers announce "list of 3 items".

<nav>  
  <ul>  
    <li><a href="index.html">Home</a></li>  
    <li><a href="about.html">About</a></li>  
    <li><a href="contact.html">Contact</a></li>  
  </ul>  
</nav>

Later, CSS will turn this into a horizontal menu and remove the bullets.


Choosing the right list

NeedUse
Items with no order (shopping, features)<ul>
Steps, rankings, instructions<ol>
Terms and definitions<dl>
Website menu<ul> inside <nav>

Common mistakes

  • Putting text directly inside <ul> or <ol> without an <li>
  • Placing a nested list outside the parent <li>
  • Using <br> or typed bullets (•) instead of real lists
  • Using <ol> when the order doesn't matter
  • Forgetting to close </li> or </ul>

Key takeaways

  • <ul> is for bullets and <ol> is for numbers. Both contain <li> items.
  • Nested lists go inside an <li>.
  • <dl>, <dt> and <dd> make description lists.
  • Navigation menus are lists of links.

Exercises (12 min)

  1. Identify (1 min). Which list type suits each of these?
    • a) Steps to make a cup of tea
    • b) Your favourite films
    • c) A glossary of web terms

    Answers: a) <ol>, b) <ul> (or <ol> if ranked), c) <dl>.
  2. Fix the errors (3 min).
    <ul>  
      Apples  
      <li>Bread</li>  
      <li>Milk  
    </ul>  
    <ol>  
      <li>Fruit</li>  
      <ul>  
        <li>Apples</li>  
      </ul>  
    </ol>

    Hints: wrap "Apples" in an <li>, close the "Milk" </li>, and move the nested <ul> inside the "Fruit" <li>.
  3. Build it (6 min). Create lists.html with:
    • an <h1> titled "My Favourites"
    • an unordered list of five foods
    • an ordered list of three steps for a simple recipe
    • a nested list with two categories, each with two items
    • a description list with three terms from this course
  4. Challenge (2 min). Build a <nav> menu with four links inside a <ul>. Add start="10" to an ordered list and check the numbering.

Lesson 6 checkpoint

  • I can create unordered and ordered lists with <li>.
  • I can nest a list inside a list item.
  • I can build a description list.
  • I can explain why menus are marked up as lists.

Keep track of your learning

Create a free account to unlock them and track your progress.

  • Track your progress through every course
  • Take the quizzes and see your score
  • Download the worksheets and resources
  • Get a certificate when you finish

Related reading on our blog

Rather have it done for you?

We build websites for small businesses

Everything in this course is what we do every day for local businesses: fast, mobile-friendly sites that are built to be found on Google. See our web design services or our website packages.