Emmanuel Akinfulubi

HTML and CSSPractical I

Create a custom bullet list in CSS

11 A custom bullet list

easy

Replace the default list markers with your own, without breaking the list for a screen reader.

Stuck? Three hints, smallest first
  1. 1. list-style: none plus a ::marker or ::before gives you control.
  2. 2. ::marker is the modern, purpose-built pseudo-element and keeps list semantics intact.
  3. 3. In Safari, list-style: none alone can remove the list role; adding role="list" restores it.

index.html

<ul class="ticks" role="list">
  <li>Air conditioning</li>
  <li>Reclining seats</li>
  <li>Onboard toilet</li>
</ul>

style.css

.ticks {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ticks li {
  padding-left: 24px;
  margin-bottom: 6px;
  position: relative;
}

/* ::before draws the marker. content is decorative, so it is hidden from
   assistive technology with an empty alt via the aria-hidden trick below. */
.ticks li::before {
  content: '\2713';        /* a tick */
  position: absolute;
  left: 0;
  color: #1e9e5a;
  font-weight: 700;
}
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 11

test('the default markers are removed', declares(css, 'list-style', 'none'), true);
test('a marker is drawn with a pseudo-element', /::before/.test(css), true);
test('it has content', /content\s*:/.test(css), true);
test('space is left for it', /padding-left\s*:\s*24px/.test(css), true);
test('it is positioned rather than floated', declares(css, 'position', 'absolute'), true);
test('a real list is used', hasTag(html, 'ul'), true);
test('three items', countTag(html, 'li'), 3);
test('role=list restores semantics Safari drops', /role="list"/.test(html), true);

Output


      

The last assertion is the non-obvious one. In Safari with VoiceOver, list-style: none removes the list role along with the bullets, so a screen reader stops announcing "list, three items". Adding role="list" back is a known, widely used workaround. If you only take one thing from this exercise, that is it.

Newsletter

New writing, when it lands.

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