Unordered & Ordered Lists

Two containers, one question: does order matter? Use `<ul>` for a bag of peers and `<ol>` when sequence is part of the meaning.

HTML5 min readConcept 8 of 42

What they are

<ul> and <ol> are the two list containers. <ul> is unordered: a collection of items where the sequence carries no meaning, a shopping list, a feature set, a group of options. <ol> is ordered: a sequence where position matters, recipe steps, a countdown, a numbered tutorial.

Both hold <li> elements and nothing else as direct children. An <li> can contain any block or inline content, including another nested list, so hierarchy comes naturally.

Why it matters

The choice between <ul> and <ol> is not cosmetic. Screen readers announce the kind of list before reading it. A numbered list primes the listener for a sequence; a bulleted list signals that the items are peers. Using <ol> for ingredients just because you like numbers tells the listener to expect a sequence where none exists.

Lists are also the right container for navigation menus, for any genuinely enumerable set, and for groups of related items that belong together conceptually. A list makes that structure visible to browsers, search engines, and assistive tech alike.

How it works

Write your items inside <li> tags, wrap them in <ul> or <ol>, and the browser renders bullets or numbers automatically. To change the marker style, reach for CSS list-style-type rather than switching the list element.

<ol> has three optional attributes that control the counter. start sets where counting begins, which is useful when one logical list is split across multiple sections of a page. reversed counts down instead of up. type switches the marker character: 1 for decimal (the default), a for lowercase letters, A for uppercase, i for lowercase roman numerals, I for uppercase roman. These are content attributes, not style, because the number itself carries meaning in a legal outline or a multi-part tutorial.

Try it

Toggle between <ul> and <ol>. When ordered, explore the start number and the reversed attribute.

<ul>
<li>Mix the flour and salt</li>
<li>Add the eggs and olive oil</li>
<li>Knead for ten minutes</li>
</ul>
  • Mix the flour and salt
  • Add the eggs and olive oil
  • Knead for ten minutes

Unordered: bullets, sequence ignored.

type

Check yourself

Pick an answer to lock it in, then read why. Getting one wrong is part of how it sticks.

  1. 1You are marking up the steps to reset a password. Which element do you use?
  2. 2A tutorial splits steps 4 to 6 into a new section. How do you make that <ol> start at 4?
  3. 3What is the only valid direct child of <ul> and <ol>?

Remember this

  • <ul> for items where order does not matter; <ol> for items where sequence is part of the meaning.
  • <ol> accepts start (first number), reversed (count down), and type (1/a/A/i/I marker style).
  • Both <ul> and <ol> take only <li> as direct children; anything else belongs inside an <li>.
  • Change bullet or number appearance with CSS list-style-type, not by switching the list element.

Done with this concept?

Mark it complete to track your progress. No login needed.