w3c / html-aria

ARIA in HTML
https://w3c.github.io/html-aria/
Other
181 stars 48 forks source link

use case for role=presentation/none and empty alt on an image #229

Closed scottaohara closed 3 years ago

scottaohara commented 4 years ago

per this html validator issue it got me wondering what use cases exist for declaring an image as presentational with alt="" but also needing to use an aria role=none / presentation.

As standard guidance is that authors should not need to use a role that is duplicative to the way in which the element is exposed, is this allowance needed? Is this to mitigate against a browser / AT bug? And if so, should that not be what's fixed instead of having a workaround?

@rianrietveld if you have a use case as to why both alt="" and role=presentation were used in your example in the validator thread, I'd be interested to hear it.

scottaohara commented 4 years ago

circling back on this @rianrietveld , still interested in your thoughts on this issue. thanks.

rianrietveld commented 3 years ago

@scottaohara I noticed the validator issue when I was writing text for a course about ARIA. I explain that an element can have a role and that you can remove that role using role=presentation. Taking an img as example.

In the code example I only used <img src="url" role="presentation">without the alt attribute, and that triggered the error.

I don’t know of any use case. For my work I always use and advice img with an empty alt attribute to remove it from the accessibility tree. No need to change a role if you don't have to.

The only use case for using role=presentation IMHO would be on a table, to fix table layout with legacy code code. Or maybe when you build complex custom widgets, something I very much stay away from.

But what I do think: it’s maybe contradictory (saying this as a non expert on writing specifications): Why should that alt attribute be present when you decide to remove the role. It’s one or the other says my gut feeling.

But for your question: do you know of a use case for both alt="" and role="presentation", no, I don’t.

scottaohara commented 3 years ago

Thank you for the response @rianrietveld

rianrietveld commented 3 years ago

@scottaohara :-) Always