← Learning Hub
Beginner

Lists

Use an unordered list <ul> when order does not matter, and an ordered list <ol> when it does, such as steps in a recipe. Each item goes inside <li>.

Lists are everywhere on websites: menus, product features, steps in a guide, search results. Using real list tags (instead of typing dashes or numbers yourself) tells the browser and screen readers "this is a list of 5 things", and CSS can then style it however you like - even as a horizontal menu bar.

An <ol> numbers items automatically, so if you add or remove a step, the numbers update by themselves.

Example
<!DOCTYPE html>
<html>
  <body>
    <h3>Shopping list</h3>
    <ul>
      <li>Rice</li>
      <li>Dal</li>
      <li>Ghee</li>
    </ul>

    <h3>How to make tea</h3>
    <ol>
      <li>Boil water with ginger.</li>
      <li>Add tea leaves and milk.</li>
      <li>Add sugar, strain and serve.</li>
    </ol>
  </body>
</html>
▶ Try it yourself
Lists can be nested: put a whole <ul> inside an <li> to make sub-items.
Key points
  • <ul> for unordered lists, <ol> for numbered ones.
  • Each item goes in <li>.
  • Navigation menus are usually lists styled with CSS.

📝 Test yourself

1. Which list shows numbers by default?
2. Which element holds each list item?
3. Fill in the tag for a bulleted list:
<>