3 ms·
It is unfortunate that nonexistent alt attribute is treated differently from empty alt attribute on images. I would prefer to add role="presentation" instead.
by strogonoff 6y ago
It is unfortunate that nonexistent alt attribute is treated differently from empty alt attribute on images. I would prefer to add role="presentation" instead.
- jscholes 6y ago> I would prefer to add role="presentation" instead. This doesn't always do what you think it does. The presentation role is for negating any accessible role implied by the use of a particular HTML element, not for hiding it entirely. For example, you've used an unordered list for appearance/styling, but it only contains one child item. In those circumstances, a list of one thing is semantically meaningless and role="presentation" on the ul is completely appropriate. The fact that applying the presentation to an img removes it from the page for screen reader users shouldn't be relied upon.
- strogonoff 6y agoDecorative graphics is prime example use case in WAI-ARIA docs for the presentation role. Its purpose is to remove the element from the accessibility tree. By comparison, alt="" is much less direct and obvious. I consider it an unfortunate historical quirk that it is not the same as a nonexistent alt attribute. For decorative images I recommend using presentation role to make the intention clear.