Lesson 13 of 36
HTML Tutorial

Ordered and Unordered Lists

Group related items with ul and ol, and tune numbering with type, start and reversed.

3 min readBeginnerWeb FundamentalsHTML Lists

Lists are everywhere: ingredients, steps, menus, navigation. HTML has two main list types. Use an unordered list when the order does not matter and an ordered list when it does.

Unordered lists#

An unordered list is created with <ul>, and each item goes in an <li> (list item). Browsers show bullets by default.

html
<h2>Our milk options</h2>
<ul>
  <li>Whole milk</li>
  <li>Oat milk</li>
  <li>Almond milk</li>
  <li>Soy milk</li>
</ul>

The only valid direct children of <ul> are <li> elements. Anything else goes inside an item.

Ordered lists#

An ordered list uses <ol>. Items are numbered automatically, so you can reorder or insert items without renumbering by hand.

html
<h2>How to brew a pour-over</h2>
<ol>
  <li>Heat the water to just below boiling.</li>
  <li>Rinse the paper filter.</li>
  <li>Add two tablespoons of ground coffee.</li>
  <li>Pour slowly in circles and wait.</li>
</ol>

If someone could swap two items without changing the meaning, it is an unordered list. If the sequence matters, such as recipe steps or rankings, it is ordered.

Controlling numbering#

Ordered lists accept three useful attributes.

html
<!-- start: begin counting from a chosen number -->
<ol start="5">
  <li>Serve in a warm cup.</li>
  <li>Add a biscuit on the side.</li>
</ol>

<!-- reversed: count down, perfect for countdowns and top-ten charts -->
<ol reversed>
  <li>Cold brew</li>
  <li>Flat white</li>
  <li>Espresso</li>
</ol>

<!-- type: choose the marker style -->
<ol type="A">
  <li>Starter</li>
  <li>Main</li>
  <li>Dessert</li>
</ol>
type valueMarker style
11, 2, 3 (default)
aa, b, c
AA, B, C
ii, ii, iii
II, II, III

You can also set a single item's number with value on the <li>. The type attribute on <ol> is still valid, but for bullets and fancy markers, CSS (list-style-type) is the modern approach. The start and reversed attributes, however, carry meaning that CSS cannot, so keep them in HTML.

Lists for navigation#

A navigation menu is really a list of links, and marking it up that way is good practice. Screen readers announce "list, 4 items", which helps users understand the menu.

html
<nav aria-label="Main">
  <ul>
    <li><a href="index.html">Home</a></li>
    <li><a href="menu.html">Menu</a></li>
    <li><a href="events.html">Events</a></li>
    <li><a href="contact.html">Contact</a></li>
  </ul>
</nav>

CSS can later remove the bullets and lay the items out horizontally. The meaning stays.

Common mistakes#

  • Typing numbers or dashes by hand inside paragraphs instead of using a real list.
  • Putting text directly inside <ul> without an <li>.
  • Using <br> to fake list items.
  • Choosing <ol> just because you want numbers visually.
  • Leaving <li> elements outside any <ul> or <ol>.

Try it yourself#

Create two lists for the cafe: an unordered list of five drinks and an ordered list of four steps for making tea. Make a third list, an ordered list counting down your "Top 3 cakes" using reversed. Finally, create a navigation menu as a list of four links inside a nav.

Recap#

Use ul when order does not matter and ol when it does, with each entry as an li. start, reversed and type tune numbering. Navigation menus are naturally lists of links.

Check your understanding

Lesson quiz

Optional

A short quiz to check what you just learned.

Questions
4
Time limit
5 min
Pass mark
70%
Best score
-