DEV Community

Discussion on: CSS can help improve your HTML⁉ - Ep 1: alt attributes

Collapse
 
ashleyjsheridan profile image
Ashley Sheridan

It's perfectly valid for an image to have an empty alt attribute, but some less experienced devs might not understand and be tempted to push unnecessary content into the attribute, making accessibility worse in some cases. The image shouldn't require the role, and the spec is clear on this that an image with empty alt text should not be part of the accessibility tree.

Collapse
 
grahamthedev profile image
GrahamTheDev • Edited

I said that it isn’t required within the article, it is a way of signalling that the alt attribute should indeed be empty to developers (and to protect against developers adding content unnecessarily). Certainly not required but something I like to do to help avoid a mess in the future.