Link

Bullets Between Inline List Items — The Accessible Way!

Direct Link →

Screen readers read pseudo elements (::before and ::after) and using bullets in them will cause it to read something like “Pizza MIDDLE DOT Döner MIDDLE DOT Kaffee”. Not good. Let’s try to fix it.

The Wrong Way

ul {
  list-style: none;
}

li {
  display: inline;
}

li + li::before {
  content: " · ";
}

Though this method is simple, it’s not accessible. Screen readers will pronounce each bullet as middle dot or something similar.

The Accessible Way

ul {
  list-style: none;
}

li {
  display: inline;
}
<ul>
  <li>Pizza <span aria-hidden="true"> · </span></li>
  <li>Döner <span aria-hidden="true"> · </span></li>
  <li>Kaffee</li>
</ul>

This solution works great for screen readers, but granted, keeping things like list bullets in the markup seems a little dirty. Using a text character as a bullet is really the only accessible solution.

Conclusion

Both solutions don’t look great on small screens, when items can’t fit on a single line. This case is a good reminder for us to be more mindful about accessibility of our sites and apps. We should do at least the basic accessibility testing and don’t always trust our intuition, like I did with this list, was wrong, and shipped inaccessible feature to production.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

All comments are held for moderation and only published when on topic and not rude. You'll even get little stars if you do an extra good job.

You may write comments in Markdown. This is the best way to post any code, inline like `<div>this</div>` or multiline blocks within triple backtick fences (```) with double new lines before and after.

Want to tell me something privately, like pointing out a typo or stuff like that? Contact Me.

icon-search icon-link