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.
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.
- Mix the flour and salt
- Add the eggs and olive oil
- Knead for ten minutes
Unordered: bullets, sequence ignored.
Check yourself
Pick an answer to lock it in, then read why. Getting one wrong is part of how it sticks.
Remember this
<ul>for items where order does not matter;<ol>for items where sequence is part of the meaning.<ol>acceptsstart(first number),reversed(count down), andtype(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.