Lists

Show items as bulleted or numbered lists.

Your HTML is drawn by your own browser, inside this tab. Nothing to install.

Bulleted lists

<ul> is a list where the order does not matter. Browsers show a bullet before each item.

Each item is an <li> element inside the list.

Only <li> elements go directly inside a <ul>.

Example
<ul>
  <li>Novels</li>
  <li>Newspapers</li>
  <li>Maps</li>
</ul>

Your turn: a bulleted list

List what the library lends.

Practice task

Write a bulleted list with exactly three items: Books, Films and Music.

Your answer is run and checked in the lesson. Create a free account to try it.

Numbered lists

<ol> is a list where the order matters, such as steps to follow. Browsers number the items for you.

The items are still <li> elements. You do not type the numbers yourself.

If you add a step in the middle later, the numbers after it change on their own.

Example
<ol>
  <li>Fill in the form</li>
  <li>Show your ID</li>
  <li>Collect your card</li>
</ol>

Your turn: a numbered list

Steps go in a numbered list.

Practice task

Write a numbered list with two steps: Find a book, then Scan your card.

Your answer is run and checked in the lesson. Create a free account to try it.

A list inside a list

A list item can hold another list. This makes sub-items.

The inner list goes inside the <li> it belongs to, before that item's closing tag.

Example
<ul>
  <li>Fiction
    <ul>
      <li>Crime</li>
      <li>Fantasy</li>
    </ul>
  </li>
  <li>Non-fiction</li>
</ul>