HTMLLesson 5 of 10Jump to practice
Lists
Group items with ul for bullet points and ol for numbered steps.
Lists are everywhere on the web: menus, shopping lists, steps, search results. HTML has two main kinds.
| Element | Name | Shows | Use it when |
|---|---|---|---|
<ul> |
Unordered list | Bullet points | The order doesn’t matter |
<ol> |
Ordered list | Numbers | The order matters |
Inside either one, every item is an <li> (list item).
Bulleted lists
<h3>Shopping list</h3>
<ul>
<li>Milk</li>
<li>Bread</li>
<li>Peanut butter</li>
</ul>Numbered lists
The browser does the numbering for you. Add an item in the middle and every number after it updates.
<h3>Making tea</h3>
<ol>
<li>Boil the water</li>
<li>Add the tea leaves</li>
<li>Add milk and sugar</li>
<li>Strain and serve</li>
</ol>Two useful attributes for <ol>:
start="5"begins counting at 5.reversedcounts down instead of up.
Lists inside lists
To nest a list, put the whole inner list inside an <li>.
<ul>
<li>Fruit
<ul>
<li>Apple</li>
<li>Banana</li>
</ul>
</li>
<li>Vegetables
<ul>
<li>Potato</li>
<li>Spinach</li>
</ul>
</li>
</ul>Practice
Check what you just learned. Fill in the missing code, then answer the quiz.
Exercise 1Solved
Turn these items into a bulleted list.
<> <li>Milk</li> <li>Bread</li> <li>Eggs</li> </>Bullets mean the order doesn't matter. The element is short for unordered list.
Exercise 2Solved
Every item in a list uses the same element. Fill it in.
<ol> <>Boil the water</> <li>Add the tea leaves</li> </ol>Exercise 3Solved
Make this numbered list start counting at 5.
<ol ="5"> <li>Fifth step</li> <li>Sixth step</li> </ol>The attribute name says where the numbering begins.
Finish the practice to complete this lesson.
Sign in to keep your progress on any device.