Skip to the workspace
Pebellslearn by building
Lists  ›  Lesson

Ordered and Unordered Lists

Ordered lists 12 minol is for items whose order matters and ul for items whose order does not, and every item in either goes inside its own li.

html / Ordered and Unordered Lists

Explore each scene at your own pace.

01 · The rule

The rule

Ordered and Unordered Lists

ol is for items whose order matters and ul for items whose order does not, and every item in either goes inside its own li.

Choose an ordered or unordered list based on whether sequence changes the meaning.

Menus, recipes, instructions, feature lists, search results: much of the web is lists. HTML has two everyday list types, and the choice between them comes down to one question about your content, not about bullets or numbers.

The rule

If shuffling changes the meaning, use ol; if not, use ul.

<ul> is an unordered list: the items belong together, but their order does not matter.

<h3>Pack for the trek</h3>
<ul>
  <li>Water bottle</li>
  <li>Rain jacket</li>
  <li>Torch</li>
</ul>

<ol> is an ordered list: the sequence is part of the meaning, like steps or rankings.

<h3>Make filter coffee</h3>
<ol>
  <li>Add coffee powder to the upper chamber.</li>
  <li>Pour boiling water over it and cover.</li>
  <li>Wait fifteen minutes, then mix the decoction with hot milk.</li>
</ol>

In both, every item is an li (list item), and li elements are the only children a ul or ol may have directly. Text or other elements go inside an li, never loose between them.

Useful ol attributes:

  • start="4" begins counting at 4, handy when a list continues after a paragraph.
  • reversed counts down, like a top-ten list ending at number one.
  • type="a", "A", "i" or "I" choose letters or Roman numerals when the numbering style is part of the meaning (as in legal clauses).

Bullets and numbers are only default styling. CSS can remove the bullets from a ul, which is exactly how most navigation menus are built: a list of links, styled not to look like a list. Screen readers still announce "list, 5 items", which helps people know what they are in.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.