If you want to know whether a website was put together by someone who actually understands web design, one good pointer is the use of the HTML ALT attribute. All too many web developers seem to not know or not care what this is for – and thereby unnecessarily reduce the accessibility of their sites.
The aim of this page is to briefly address how, and how not, to use it. The writing of good ALT texts is not always easy, and what constitutes a good ALT text is a matter of much discussion. But if you follow the advice on this page, you will at least be doing better than most web authors.
So what is ALT for? As the HTML specification says:
“Several non-textual elements (IMG, AREA, APPLET, and INPUT) let authors specify alternate text to serve as content when the element cannot be rendered normally.” (section 13.8)
“The alt attribute specifies alternate text that is rendered when the image cannot be displayed ... User agents must render alternate text when they cannot support images, they cannot support a certain image type or when they are configured not to display images.” (section 13.2)
The purpose of the ALT attribute is thus to provide in textual form whatever information was provided by the image.
One of the reasons this can sometimes be tricky is that there are two main target groups, with somewhat different needs:
The first group is probably more numerous, but the second group is more important, since they have no choice in the matter. ALT texts are also of importance for search engines, which can typically do little with images, but can handle the alternative text.
For the purposes of ALT texts, most images fall into one of the following categories.
To check that the texts are reasonable, simply switch images off in your browser and reload the page. Or better still, look at the page in a text browser. You may find you need to add some punctuation, or a trailing space.
Of course some pages are intrinsically visual, where no ALT or LONGDESC text can possibly provide a reasonable alternative. It is unlikely however that these constitute more than a small fraction of the pages on the web.
Should you want a much more detailed discussion, see Jukka Korpela's Guidelines on alt texts in img elements, which also includes links to other relevant pages.
One commonly made comment is that one might as well omit the ALT attribute from decorative images, as ALT="" is just the same. Well no, it is not the same.
In the first case a text browser normally shows nothing at all. In the second case it may insert [Image] or [Inline] or the name of the file, to indicate that there is something there.
To give an idea of the effect of omitting ALT attributes, here is the complete, unabridged home page of a fairly large multinational company, as seen through a text browser:[INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [LINK] [INLINE] [INLINE] [INLINE] [INLINE] [LINK] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [LINK] [INLINE] [INLINE] [INLINE] [INLINE] [LINK] [INLINE] [INLINE] [INLINE] [LINK] [LINK] [INLINE] [INLINE] [LINK] [LINK] [INLINE] [INLINE] [LINK] [LINK] [INLINE] [LINK] [INLINE] [LINK] [INLINE] [INLINE] [INLINE] [LINK] [LINK] [LINK] [LINK] [INLINE] [INLINE] [LINK] [LINK] [INLINE] [INLINE] [INLINE] [LINK] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE] [INLINE]
And this company includes IT among its services. How much would this encourage you to buy from them?
Occasionally one comes across sites where the author has blindly put an ALT text on all images, including the decorative ones. So one gets an almost unreadable mess like:
spacer-GIF Home Blue diamond Products Blue diamond Services Blue diamond Vacancies spacer-GIF
I am indebted to the late Alan Flavell for the following classic example from the web site of the US Embassy in Belgrade:
Small red bullet Response to Terrorism
For some further examples see his page of howlers, fortunately preserved.
Some screen-based browsers display the ALT text temporarily (as a “tool-tip”) if one hovers over the image with a mouse. This is not the intended use of ALT, but it is not a major fault – though some readers do find it irritating.
As a result of this, some authors make the mistake of including text in the ALT attribute which is relevant to all readers, not just those who can't see the images. People using other browsers can then not see the text, nor those readers who are using a keyboard, or who have disabled tool-tips, nor those with printed copies.
Use of the TITLE attribute is better in this case, but if the information is important it is best simply to include an explicit text caption above or below the image.