# Ordered and Unordered Lists

HTML has two everyday lists, an unordered list for items whose order doesn't matter and an ordered list for steps and rankings, with each item in its own list item.

Novice · HTML · Updated October 31, 2026

## After this lesson you can

- Choose an ordered or an unordered list by whether the order of the items matters
- Write a list with ul or ol and li, and nest a list inside a list item
- Number an ordered list with start and reversed

## Key takeaways

- Use `<ul>`, an unordered list, when the order doesn't change the meaning, such as a shopping list or a menu of links.
- Use `<ol>`, an ordered list, when the order matters, such as recipe steps or a top 10. The browser numbers the items for you.
- Every item goes in its own `<li>`, and a list holds only `<li>` elements directly inside it.
- To nest a list, put the whole inner list inside one of the outer list's `<li>` elements, before its closing tag.
- On an `<ol>`, `start` picks the first number and `reversed` makes the list count down.

You use lists all the time without thinking about it: a shopping list on the fridge, the steps on a box of pancake mix, a top-10 countdown on the radio. Web pages are full of them too. A store's menu of links, the steps to reset a password and the leaderboard on a game site are all lists. Whenever you build a page, for a class assignment, a club or a job, you'll write a list in it almost every time.

HTML has two everyday kinds of list, and choosing between them comes down to one question: **does the order matter?**

This chapter builds pages for **Galaxy Blasters**, a made-up retro arcade with a space-shooter game, a prize counter and a snack bar. By the end of the chapter you'll have built its high-score board.

## Does the order matter?

Think about a shopping list. You can grab the milk before the bread or after it, and it's still the same list. Now think about a pancake recipe. If you pour the batter into the pan before you mix it, breakfast goes wrong. The order of the steps is part of what they mean.

HTML has a list for each case:

- An **unordered list** is a list whose order doesn't change its meaning: a shopping list, the games an arcade has, the toppings on a pizza. Browsers show a bullet (a small dot) beside each item.
- An **ordered list** is a list whose order is part of its meaning: steps, directions, a ranking. Browsers number the items: 1, 2, 3.

Word processors call these a *bulleted list* and a *numbered list*. Those names describe how they look; HTML's names describe what they mean, and the meaning is what you choose by.

![A shopping list next to recipe steps: shuffling the shopping list changes nothing, while shuffling the recipe steps ruins the pancakes](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/10/493fd132228948e980f27dd30fe34b9b.webp)

## Unordered lists: ul and li

An unordered list is written with `<ul>`, read "U L", short for *unordered list*. Each item inside it is a **list item**, written `<li>` and read "L I":

```html
<h2>Games on the floor</h2>
<ul>
    <li>Galaxy Blasters</li>
    <li>Turbo Kart Rally</li>
    <li>Neon Air Hockey</li>
    <li>Mega Claw</li>
</ul>
```

The `<ul>` element wraps the whole list, and each `<li>` holds one item. The browser shows the four games one under another, each with a bullet.

Notice where the heading is: outside the list, above it. Inside a `<ul>`, the only elements allowed directly are `<li>` elements. A heading, a paragraph or a bare line of text goes outside the list, or inside one of its `<li>` elements. An `<li>` can hold other elements, such as `<strong>` around a word that's important; the `<ul>` itself holds only `<li>` elements.

That rule matters most for people who use a **screen reader**: a program that reads the page aloud, used by people who are blind or can't see the screen well. When a screen reader reaches a list, it says something like "list, 4 items", so the listener knows how long the list is and can skip past it. A list with stray text inside it gets announced with the wrong count, or not as a list at all.

**Try it.** In VS Code, make a new file named `arcade-lists.html` in your practice folder. Type `!` and press **Tab** to get the page skeleton, then add the list above inside `<body>`. Open the page with Live Server, and add a fifth game of your own.

## Ordered lists: ol

An ordered list is written with `<ol>`, read "O L", short for *ordered list*. Its items are `<li>` elements too:

```html
<h2>How to play Galaxy Blasters</h2>
<ol>
    <li>Drop a token in the slot.</li>
    <li>Press the green Start button.</li>
    <li>Steer your ship with the joystick.</li>
    <li>Press Fire to blast the asteroids.</li>
</ol>
```

You don't type the numbers. The browser numbers the items 1 to 4, in the order they appear in the code. Move a step up or down in the code, and the numbers follow. If you typed "1." yourself, you'd have to renumber every step by hand each time. The same rule holds as for `<ul>`: only `<li>` elements go directly inside an `<ol>`.

## Lists inside lists

Sometimes an item has items of its own, like a school outline with points under each heading. Putting one element inside another is called **nesting**, and a list inside a list is a *nested list*. The inner list goes **inside** an `<li>` of the outer list, before that item's closing `</li>`:

```html
<h2>Prize counter</h2>
<ul>
    <li>Under 100 tickets
        <ul>
            <li>Alien sticker</li>
            <li>Bouncy ball</li>
        </ul>
    </li>
    <li>100 tickets or more
        <ul>
            <li>Glow-in-the-dark yo-yo</li>
            <li>Rocket keychain</li>
        </ul>
    </li>
</ul>
```

The outer list has two items, and each one holds a list of two prizes. Indenting the inner list shows the nesting at a glance; the browser indents it on the page too, and gives its items a different bullet. You can mix the two kinds as well: an `<ol>` of steps can have a `<ul>` of tips inside one of its steps.

**Try it.** Add the prize counter to `arcade-lists.html`. Then add a third group, "500 tickets or more", with a prize you'd want to win.

## Lists of links: a site's menu

Look at the menu across the top of almost any website: Home, Games, Parties, Contact. It's a list of links, and the order doesn't change what the links mean, so it's a `<ul>`. Each item holds a link (`<a>`), and the whole list usually sits inside `<nav>`, the element for a block of navigation links:

```html
<nav>
    <ul>
        <li><a href="index.html">Home</a></li>
        <li><a href="games.html">Games</a></li>
        <li><a href="parties.html">Birthday parties</a></li>
    </ul>
</nav>
```

A screen reader announces something like "navigation, list, 3 items", so a listener knows there are three places to go before hearing them. The bullets can be switched off with CSS, which is how a plain list of links becomes the menu bar you see on real sites. A menu with drop-down groups, such as Games, then Classic and Racing under it, is a nested list.

## Counting from somewhere else: start and reversed

An ordered list doesn't have to count 1, 2, 3. Two attributes change its numbering. (An **attribute** is extra information in an element's opening tag, written as a name, `=` and a value in quotes.)

- `start` sets the first number. A list of places 6 to 10, on a page after places 1 to 5, starts at 6: `<ol start="6">`.
- `reversed` makes the list count down, like a top-10 countdown on the radio. It's a **boolean attribute**: it's either there or not, like a light switch, so it needs no value. Writing `reversed` switches it on.

Here's the arcade's top-five countdown. The code lists fifth place first, and the browser numbers it 5, 4, 3, 2, 1, so the winner comes last with the number 1:

```html
<h2>Top five countdown</h2>
<ol reversed>
    <li>LASERLOU: 78,640</li>
    <li>COMETCAT: 82,310</li>
    <li>NOVAKID: 87,925</li>
    <li>STARFOX99: 91,200</li>
    <li>PIXELPAM: 98,450</li>
</ol>
```

With `reversed`, the browser counts how many items the list has and starts from there: five items count down from 5, ten count down from 10. You can use both attributes together too: `<ol reversed start="10">` counts down from 10, however many items there are.

**Try it.** Add the countdown to your page. Change it to `<ol reversed start="10">` and watch the numbers go 10 to 6. Then remove `reversed` and see what `start="10"` does on its own.

## Check yourself

3 questions to try on the lesson page.

## So what

Menus, steps, rankings and checklists are all lists, so you'll write `<ul>`, `<ol>` and `<li>` on nearly every page you build. Ask "does the order matter?", and the right list tells browsers and screen readers what kind of list it is.

## Key terms

- [Unordered list](https://www.ask-codey.com/glossary/unordered-list)
- [Ordered list](https://www.ask-codey.com/glossary/ordered-list)
- [List item](https://www.ask-codey.com/glossary/list-item)
- [Nesting](https://www.ask-codey.com/glossary/nesting)
- [Boolean attribute](https://www.ask-codey.com/glossary/boolean-attribute)

## Cheat sheets

- [Ordered and Unordered Lists](https://www.ask-codey.com/cheat-sheets/html-ordered-and-unordered-lists-cheat-sheet)

## Related

- [Description Lists](https://www.ask-codey.com/lessons/html-description-lists)

Source: https://www.ask-codey.com/lessons/html-ordered-and-unordered-lists
