freecourses.digital
Lesson progress: 0 of 3 activities done
All lessons in HTML Basics for Beginners Lesson 3.4 of 34

Module 10: Practice Project and Validation

  1. 10.1Build a simple HTML website

Ordered and unordered lists

This lesson covers

  • Unordered lists with <ul>
  • Ordered lists with <ol> and its attributes
  • Nested lists
  • Description lists with <dl>

Short answer

Use <ul> for a list where order does not matter, like features or ingredients. Use <ol> when order matters, like steps or rankings. Each item goes in <li>. For terms and definitions, like an FAQ or glossary, use a description list with <dl>, <dt>, and <dd>.

Unordered lists

<ul>
  <li>Free Wi-Fi</li>
  <li>Pool with Mayon view</li>
  <li>Airport pickup</li>
</ul>

Browsers show bullets by default. Screen readers announce list, 3 items, which helps users know how much is coming.

Ordered lists

<ol>
  <li>Wash the rice.</li>
  <li>Add water to the first knuckle.</li>
  <li>Cook for 20 minutes.</li>
</ol>

Useful attributes:

  • start="5" begins counting at 5.
  • reversed counts down, nice for a top 10 list.
  • type="A" uses letters, type="i" uses Roman numerals.

Nested lists

Put a whole list inside an <li> to make sub items:

<ul>
  <li>Albay
    <ul>
      <li>Legazpi</li>
      <li>Daraga</li>
    </ul>
  </li>
  <li>Sorsogon</li>
</ul>

The inner list goes inside the li, before its closing tag. Only <li> may be a direct child of ul or ol.

Description lists

<dl>
  <dt>Laing</dt>
  <dd>Taro leaves cooked in coconut milk.</dd>
  <dt>Pinangat</dt>
  <dd>Laing wrapped in taro leaf parcels.</dd>
</dl>

dt is the term, dd is the description. Glossaries, FAQs, and spec sheets fit well. The Key terms section on this page is a description list.

Try it: build a recipe

Turn the ingredients into an unordered list and the steps into an ordered list.

Live preview

Quick quiz

1. Which list fits step by step instructions?
2. What may be a direct child of <ul>?
3. Which tag holds a term in a description list?
4. Where does a nested list go?

Common mistakes

  • Fake lists with dashes or br. Typed dashes are not real lists for screen readers.
  • Putting text directly in ul. Every item needs an li.
  • Using ol for unordered items. Numbers imply a sequence that does not exist.

Your action

Tick each item when you can do it. Your progress saves on this device.

Key terms

<ul>
Unordered list.
<ol>
Ordered list.
<li>
List item.
Nested list
A list inside a list item.
<dl>
Description list of terms and details.

Questions beginners ask

How do I remove bullets?

Use CSS: list-style: none. Keep the ul for meaning.

Are navigation menus lists?

Often, yes. A menu is a list of links, as you will see in Lesson 4.4.

Can li hold paragraphs or images?

Yes. An li can contain most content.

Related lessons

Need a website built or fixed while you practice? The team at Remar Digital can help.