3 ms·
I started writing an article in March entitled “<img alt> should be empty”, arguing the radical position that every image tag should have an empty alt attribute
by chrismorgan 6y ago
I started writing an article in March entitled “<img alt> should be empty”, arguing the radical position that every image tag should have an empty alt attribute. I don’t quite hold that opinion in reality, but it’s pretty close. I stopped writing it because I was poking a few too many holes in my position, but I still hold to the bones of it.
The primary categories of images that exist are:
• Decorative or ornamental imagery. Part of art direction; typically implemented with CSS (commonly background images) rather than <img> these days.
• Stock imagery. Part of art direction. An annoying waste of time, space and bandwidth that is unfortunately valuable because of human psychology.
• Meaningful figures: photos, diagrams and other images that are actually related to the content.
Art direction <img> tags should always have an empty alt attribute, even stock imagery: because it’s not adding anything to the content. (I hear someone crying, “but I put that stock image there for a reason!” Sure, you put it there to manipulate a particular facet of human psychology, but it’s purely a visual phenomenon, and it doesn’t transfer to other media at all. In fact, rendered to speech it’ll have the opposite effect, so drop it like a hot potato. There are equivalent phenomena for other senses, e.g. there’s a reason audiobooks, podcasts, &c. add music; but you can’t do that in this place.)
What remains, then, is the meaningful figures; and for that, I hold that images should basically always be described in the visible text anyway, typically as a <figure> with a <figcaption>. And if you have a <figcaption> describing the image sufficiently, I see no cause for any image tag to have anything but empty alt text, because you shouldn’t be writing the same thing again, and there’s no other useful value. Some decry this, and insist figcaption and alt serve different purposes and you should have both, e.g. https://www.scottohara.me/blog/2019/01/21/how-do-you-figure.html#a-figcaption-is-not-a-substitute-for-alt-text https://www.scottohara.me/blog/2019/01/21/how-do-you-figure...., part of an article which another decent resource https://webaim.org/techniques/alttext/#figure https://webaim.org/techniques/alttext/#figure cites, but I disagree with the argument and its conclusions—especially its “if you empty the alt then the figcaption is not describing anything”, because the figcaption was never describing the image in the first place, but rather the figure, which is still there. Hiding the image in this way because it has been fully described is thus perfectly reasonable.
(Related: avatar images that are paired with the user name in text should have empty alt text. Otherwise you get the name twice in a row. In this case, the image is effectively ornamental, just like icons on buttons that also have labels are ornamental. I receive emails from multiple systems and interact with multiple web apps that commit this sin. It’s annoying, especially when they style things in such a way that the visual presentation of alt text when the image is not loaded is broken anyway.)
So the main case that people might think is left is diagrams where a figcaption would say “the results of such-and-such a benchmark” or similar. But even then the alt text should quite probably be empty: remember also that alt text shouldn’t be too long; the picture may be worth a thousand words, but alt text should not be even a tenth of that length, so you probably shouldn’t list all the values of a bar chart in alt text. Rather, any details that matter, draw attention to them in the caption or the prose surrounding the image! Also most diagrams would be better done as SVG, and if you do that you have much finer control over accessibility presentation than alt text, as well. Though you still have to be careful about pushing too much information to the screen reader.
To be clear, I’m not saying that everyone should take their documents and document.querySelectorAll('img').forEach(e => e.alt = ''), but rather that they should strongly consider designing their documents and massaging their content to the point where that is reasonable, with writing good captions and the likes.
- srtjstjsj 6y ago> basically always be described in the visible text anyway, Is a bridge too far. Sure you should summarize the key takeway of a chart, but a chart has a lot of detail that sighted users don't need to reread in a worse layout, but blind users need a way to access.
- felixfbecker 6y agoI think ideally those charts would be SVGs that can have elements with their own ARIA labels and be navigated by a screen reader. It would be very clumsy to describe an entire chart in an alt text string.
- chrismorgan 6y agoI think we’re in agreement, just that you understood what I wrote a bit differently from how I intended. By “described in the visible text” I didn’t mean “expounded at length”. I’m talking most commonly about the sort of captions newspapers printed with images, typically 5–30 words; but also about things in the text that refer to the figure, like “here are the benchmark results:” and “we see that X is 57% faster than Y”. There’s no good way of exposing lengthy information about a chart to screen readers. Don’t try doing it via alt, it’s a bad experience; and don’t try doing it by screen-reader-only text, that just gets confusing. The longdesc attribute was an attempt to do this, but it failed to gain traction among users or assistance tech. Consensus now is that you should instead include in the caption a link to a page that focuses just on the chart, which can then include more detail for the screen readers.
- jscholes 6y ago> Hiding the image in this way because it has been fully described is thus perfectly reasonable. I disagree as a screen reader user. To be clear, I completely support your assertions around describing complex imagery, e.g. the alt text is a completely inappropriate place to describe a graph, chart, etc. But a figcaption with no accompanying figure content is semantically wrong. If you have a figure with a textual description or semantic representation of the data displayed in an image, e.g. a table behind a disclosure button, then fine: the figure body is meaningful, as is the caption. But if I'm testing a site and find cases of figures where the only screen-reader-accessible element is the figcaption, that is an antipattern that I will insist be addressed.