HTML Lists
Lists group related items together. They're everywhere on the web: navigation menus, shopping lists, step-by-step instructions, glossaries. HTML has three kinds of list.
| List type | Container | Item element | Use it when… |
|---|---|---|---|
| Unordered | <ul> |
<li> |
Order doesn't matter (bullets) |
| Ordered | <ol> |
<li> |
Order matters (numbers or letters) |
| Description | <dl> |
<dt> + <dd> |
Pairing terms with descriptions |
Unordered lists
An unordered list shows a bullet before each item. Every item goes in its own <li> (list item) element.
<h3>Packing list</h3>
<ul>
<li>Toothbrush</li>
<li>Sunscreen</li>
<li>Phone charger</li>
<li>Swimsuit</li>
</ul>You can change the bullet with the CSS list-style-type property: disc (default), circle, square or none.
Ordered lists
An ordered list numbers its items automatically. If you add, remove or reorder items, the numbers update for you.
<h3>Make a cup of tea</h3>
<ol>
<li>Boil the water.</li>
<li>Put a tea bag in the cup.</li>
<li>Pour in the water and wait three minutes.</li>
<li>Remove the bag and enjoy.</li>
</ol>
<h3>Top three, counted down</h3>
<ol reversed>
<li>Bronze</li>
<li>Silver</li>
<li>Gold</li>
</ol>
<h3>Chapters starting at C</h3>
<ol type="A" start="3">
<li>Variables</li>
<li>Loops</li>
</ol>Attributes for <ol>:
| Attribute | Example | Effect |
|---|---|---|
type |
type="a" |
Marker style: 1, A, a, I, i |
start |
start="5" |
First number to count from |
reversed |
reversed |
Count downwards |
An individual <li> inside an <ol> can also take a value attribute to jump to a specific number.
Description lists
A description list pairs a term (<dt>) with one or more descriptions (<dd>). It is perfect for glossaries, FAQs and metadata such as "Author: …".
<dl>
<dt>HTML</dt>
<dd>The markup language that structures web pages.</dd>
<dt>CSS</dt>
<dd>The language that styles them.</dd>
<dt>JavaScript</dt>
<dd>The language that makes them interactive.</dd>
</dl>Nested lists
A list can contain another list. Put the inner list inside an <li>, not directly inside the outer <ul> or <ol>.
<ul>
<li>Fruit
<ul>
<li>Apples</li>
<li>Pears</li>
</ul>
</li>
<li>Vegetables
<ol>
<li>Carrots</li>
<li>Peas</li>
</ol>
</li>
</ul>Note: The only elements allowed directly inside
<ul>and<ol>are<li>elements (plus<script>and<template>). Headings, paragraphs and other lists must go inside an<li>.
Lists as navigation menus
Most site menus are really unordered lists with the bullets removed and the items laid out in a row. This is good structure: screen readers announce "list, 4 items", so users know how many links to expect.
<style>
nav ul {
list-style-type: none;
margin: 0;
padding: 0;
display: flex;
gap: 4px;
background: #2b2b2b;
font-family: sans-serif;
}
nav a {
display: block;
padding: 12px 16px;
color: white;
text-decoration: none;
}
nav a:hover { background: #e34c26; }
</style>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Projects</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>Styling list markers
| CSS property | Example | Effect |
|---|---|---|
list-style-type |
square, upper-roman, none |
Marker shape or numbering style |
list-style-position |
inside / outside |
Marker inside or outside the text box |
list-style-image |
url(star.svg) |
Use an image as the bullet |
::marker |
li::marker { color: red; } |
Style the marker itself |
Tip: Choose the list type for its meaning, not its look. If the order matters (steps, rankings), use
<ol>even if you later hide the numbers with CSS.
Test yourself
Which element creates a numbered list?
<ul><ol><dl><nl>
In a description list, which element holds the term being described?
<dd><li><dt><term>
Where should a nested list be placed?
- Directly inside the outer
<ul> - Inside an
<li>of the outer list - After the outer list closes
- Inside a
<dt>