On this page10 sections
  1. Learning Objectives
  2. 1. Unordered (Bullet) Lists
  3. 2. Ordered (Numbered) Lists
  4. 3. Changing the Numbering
  5. 4. Nested Lists
  6. 5. Description Lists
  7. Common Beginner Mistakes
  8. Practice Questions
  9. Practice Answers
  10. Key Takeaways

Lecture 015: Lists

Category3: Links, Images, Tables & Lists
Lecture015 of 048
Estimated video length10 min
TargetHTML5 · any modern browser
LevelBeginner

Shopping lists, recipe steps, menus: a lot of content is naturally a list. HTML has three kinds: bullet lists, numbered lists, and lists of terms with their meanings.


Learning Objectives

  • Build bullet lists with <ul> and numbered lists with <ol>
  • Nest one list inside another
  • Change numbering with start, reversed and type
  • Write description lists with <dl>, <dt> and <dd>

1. Unordered (Bullet) Lists

Use <ul> when the order doesn't matter. Each item is an <li> (list item).

Example

html
<h3>Shopping list</h3>
<ul>
  <li>Milk</li>
  <li>Eggs</li>
  <li>Bread</li>
</ul>

2. Ordered (Numbered) Lists

Use <ol> when the order does matter, such as steps.

Example

html
<h3>Make tea</h3>
<ol>
  <li>Boil water</li>
  <li>Add tea leaves</li>
  <li>Add milk and sugar</li>
  <li>Strain and serve</li>
</ol>

The browser numbers the items for you. Add or remove a step and the numbers update themselves.


3. Changing the Numbering

AttributeEffect
start="5"Begin counting at 5
reversedCount down
type="A"Use A, B, C… (also a, I, i)

Example

html
<h3>Top 3 cities</h3>
<ol reversed>
  <li>Islamabad</li>
  <li>Lahore</li>
  <li>Karachi</li>
</ol>

<h3>Choose one</h3>
<ol type="A">
  <li>True</li>
  <li>False</li>
</ol>

4. Nested Lists

Put a whole new list inside an <li> to make sub-items.

Example

html
<ul>
  <li>Fruit
    <ul>
      <li>Mango</li>
      <li>Banana</li>
    </ul>
  </li>
  <li>Vegetables
    <ul>
      <li>Spinach</li>
      <li>Carrots</li>
    </ul>
  </li>
</ul>

5. Description Lists

A <dl> pairs terms (<dt>) with their descriptions (<dd>), like a glossary.

Example

html
<dl>
  <dt>HTML</dt>
  <dd>The structure of a web page.</dd>
  <dt>CSS</dt>
  <dd>The styling of a web page.</dd>
</dl>

Common Beginner Mistakes

1. Text directly inside <ul>. Only <li> elements may sit directly inside <ul> and <ol>.

2. Nested list outside the <li>. The inner <ul> must go inside the parent <li>, before its </li>.

3. Typing the numbers yourself. <li>1. Boil water</li> in an <ol> shows "1. 1. Boil water". Let <ol> do the counting.

4. Using lists just for indentation. If the content isn't really a list, use CSS for spacing.


Practice Questions

  1. Which list would you use for the steps of a recipe?
  2. What element is every list item wrapped in?
  3. Make a numbered list that starts at 10.
  4. Where does a nested list go?
  5. Which elements make a glossary of terms and meanings?
  6. Write a bullet list of three programming languages.

Practice Answers

  1. An ordered list, <ol>.
  2. <li>
  3. <ol start="10"><li>…</li></ol>
  4. Inside the parent <li>, before its closing </li>.
  5. <dl>, <dt> and <dd>.
  6. html
    <ul>
      <li>Dart</li>
      <li>Python</li>
      <li>JavaScript</li>
    </ul>

Key Takeaways

  • <ul> for bullets (order doesn't matter), <ol> for numbers (order matters).
  • Every item is an <li>; nested lists go inside an <li>.
  • start, reversed and type change how an <ol> counts.
  • <dl> / <dt> / <dd> pair terms with their meanings.