I had a list like this on my site for a long time:
Pizza · Döner · Kaffee
Until I’ve tried it in a screen reader and realized that a screen reader reads pseudo elements (::before and ::after) content that I was using to implement bullets.
A screen reader will read something like “Pizza MIDDLE DOT Döner MIDDLE DOT Kaffee”. Not good. Let’s try to fix it.
This is my original solution with a bullet character in a ::before pseudo element and adjacent sibling selector to show it only between elements, not in front of each element:
Cons. I don’t like keeping things like list bullets in the markup if I can avoid that, but to use a text character as a bullet, this may be your only solution.
This is my final solution. It’s based on the initial, wrong, solution with pseudo element, but uses graphics for bullets. It can be CSS for simple shapes, like a circle or an arrow, or SVG for more complex shapes.
I have just a circle, so I’m using CSS:
I’ve added display: flex to the ul to make it independent from possible whitespace in HTML.
Both solutions don’t look great on small screens, when items can’t fit on a single line. I don’t know a perfect way to this, so consider it a homework. Let me know if you have find something good.
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.