Emmanuel Akinfulubi

HTML and CSSHTML and CSS

Ordered vs unordered lists in HTML

7 Ordered where order matters

easy

Write one list where the sequence is part of the meaning and one where it is not. Then start the numbered one at a value other than 1.

Stuck? Three hints, smallest first
  1. 1. <ol> for steps and rankings, <ul> for a set of things.
  2. 2. start sets the first number; type changes the numeral style.
  3. 3. Reordering a <ul> changes nothing. Reordering an <ol> changes the meaning — that is the test for which to use.

index.html

<h2>Buying a ticket</h2>
<ol start="2">
  <li>Join the queue at the window marked for your route.</li>
  <li>Pay and take the printed slip.</li>
  <li>Show the slip at the bay.</li>
</ol>

<h2>On board</h2>
<ul>
  <li>Air conditioning</li>
  <li>Reclining seats</li>
  <li>One free bag</li>
</ul>

style.css

ol, ul {
  margin: 0 0 1rem;
  padding-left: 1.4rem;
}

li {
  margin-bottom: 0.3rem;
  line-height: 1.5;
}

ol li::marker {
  color: #3055d8;
  font-weight: 600;
}
Rendered result. Shown, not machine-checked: there is no browser in the build.
8 checks that prove this answer

Assertions, run in the browser. The markup and styles above are handed to them as html and css, so press Run and each check prints ok. The build fails if a single one fails.

Checks for exercise 7

test('the steps are an ordered list', hasTag(html, 'ol'), true);
test('the features are an unordered list', hasTag(html, 'ul'), true);
test('the numbering starts at 2', /<ol start="2">/.test(html), true);
test('six items in total', countTag(html, 'li'), 6);
test('the markers are styled through ::marker', /::marker/.test(css), true);
test('only the ordered list gets that treatment', /ol li::marker/.test(css), true);
test('the indent comes from padding, not a margin hack', /padding-left\s*:\s*1\.4rem/.test(css), true);
test('each list is introduced by a heading', countTag(html, 'h2'), 2);

Output


      

The question to ask is whether shuffling the items changes what the page says. Steps two, three and four cannot be swapped; air conditioning and reclining seats can. Assistive technology announces the count either way, but only <ol> announces position, so choosing the wrong one loses information that was in your head and never made it into the markup. start exists precisely so a list continued after a break keeps its real numbers instead of restarting at one.

Newsletter

New writing, when it lands.

Occasional notes on shipping software with AI agents. No schedule, no filler, unsubscribe in one click.