Lists
Shopping lists, steps in a recipe, menu links, FAQs — lists are everywhere. HTML has three kinds, each with its own job.
On this page · 5 min · Beginner
On this page
- Learning objectives
- Explanation
- Syntax
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Beginner
- Updated
- Oct 28, 2026
Related tutorials
Learning objectives#
- Create unordered lists with <ul>
- Create numbered lists with <ol>
- Nest a list inside another
- Use description lists for term–definition pairs
Explanation#
<ul> (unordered list) is for items where order does not matter. Each item is an <li>. Browsers show bullets.
<ol> (ordered list) is for steps where order matters. Browsers number them. start="5" begins at 5; reversed counts down; type="A" uses letters.
To nest, put the whole inner <ul> or <ol> inside an <li> — not directly inside the outer list.
<dl> (description list) pairs terms <dt> with descriptions <dd>: glossaries, FAQs, product specifications.
Syntax#
<ul> <li>Item</li> </ul>
<ol> <li>Step</li> </ol>
<dl> <dt>Term</dt> <dd>Description</dd> </dl>
Code example: All three list types#
<h3>Groceries</h3>
<ul>
<li>Rice</li>
<li>Vegetables
<ul>
<li>Onions</li>
<li>Tomatoes</li>
</ul>
</li>
<li>Milk</li>
</ul>
<h3>Make tea</h3>
<ol>
<li>Boil water</li>
<li>Add tea leaves</li>
<li>Add milk and sugar</li>
</ol>
<h3>Specifications</h3>
<dl>
<dt>Weight</dt><dd>1.2 kg</dd>
<dt>Battery</dt><dd>10 hours</dd>
</dl>
A bulleted grocery list with a nested sub-list, a numbered list of steps and a list of specifications.
Step-by-step explanation#
- The grocery list uses <ul> because order does not matter.
- The nested <ul> lives inside the “Vegetables” <li>.
- The tea steps use <ol> because doing them out of order would ruin the tea.
- <dl> pairs each spec name (<dt>) with its value (<dd>).
Real-world use case#
Navigation menus are <ul> lists styled horizontally with CSS. Checkout steps and tutorials use <ol>. Product spec tables and FAQs often use <dl>.
Common mistakes#
Only <li> may be a direct child of <ul> or <ol>. Wrap every item in <li>.
<!-- ✗ -->
<ul>Rice</ul>
<!-- ✓ -->
<ul><li>Rice</li></ul>
<ul><li>A</li><ul>…</ul></ul> is invalid. The inner list must be inside an <li>.
Writing “1.” “2.” in <p> tags means renumbering everything when you add a step. <ol> numbers automatically.
Best practices#
- Use <ol> when order matters, <ul> when it does not
- Use CSS list-style to change bullets, not images in the HTML
- Keep nesting to two levels where possible
- Use lists for menus — screen readers announce “list, 4 items”
Remember this#
ul = unordered (bullets) • ol = ordered (numbers) • dl = dictionary (term + meaning).
li = list item — the only child a ul/ol may have.
Nested list? It lives inside an li.
Practice exercise#
Your task: Make an ordered list of 3 steps to start a computer, where step 2 has a nested unordered list of two sub-points.
Need a hint?
Show solution
<ol>
<li>Press the power button</li>
<li>Log in
<ul>
<li>Enter your username</li>
<li>Enter your password</li>
</ul>
</li>
<li>Open your apps</li>
</ol>
Mini quiz#
Which list suits the steps of a recipe?
Want more? Practise all HTML MCQs · HTML interview questions
My notes#
Saved in this browser.