"Fixing" lists | Scott O'Hara
I've long "known" that if you set list-style: none
on a <ul>
or <ol>
, then you "should" add role="list"
to that element as well. If you don't, Safari/VoiceOver will ignore the inherent semantics of the list, and AT users will get incorrect information.
Turns out there's a bit more nuance to this distinction. Scott's article is one of the best (and first) to dig into the issue, and is kept up to date, so is definitely worth referencing.
Re-reading it has certainly made me reconsider my approach (I literally have this baked into my CSS resets). After all, a cardinal rule of accessibility work is "provide the same experience, as closely as possible, to all people". For something like a styled contents table, or customised list bullets, re-adding that ARIA role makes sense. But as a sighted, mouse user, I have no idea how many items are in a feed list, yet a list it is. In the past I would have dogmatically added role="list"
here as well, but now I'm questioning that.
As always, nuance matters.
On an update (that I was unaware of) to do with navigation menus and lists:
There have been additional updates to how Safari exposes list semantics based on their nesting context. For instance, if a list is a descendant of a
<nav>
element, then even if the list styles are removed, Safari/VoiceOver will expose this as a list to users.
On Scott's thoughts around the root complexity/issue with Safari's decision:
I find myself a bit torn here. The decision to remove list semantics if a list is no longer styled to look like a list does make sense… Typically I think it’s important for elements to look like what they are. But a blanket decision like this can get into some opinionated territory. It also discounts the fact that there are other ways to visually interpret lists than just if they have default list markers, such as bullets.