Alt Text

Post details

The first commandment of Web Accessibility is to "Provide a text equivalent for every non-text element". Unfortunately, this is more often easier said than done, with inappropriate alt text often being the cause of many sites failing to reach even Single-A. So here is our guide to best practice alt text. First up, some clarifications:

  • Every image must have an alt attribute, but not every image needs alt text.
  • There's no such thing as an alt tag.
  • The purpose of alt is not to display a tooltip. Microsoft, in their wisdom, decided that this would be a nice feature, and implemented it in Internet Explorer. Firefox, and other browsers which implement the spec as it was intended, correctly don't display alt as a tooltip. If a tooltip doesn't show up in your browser when you hover over an image, it doesn't necessarily mean the image doesn't have alt, or the site is inaccessible.
  • You don't need to preface every alt text with "graphic", "image" or "photo" (except in specific instances, see below)

When it comes to writing alt text, all images are definitely not created equally. Alt text needs to be written according to the purpose of the image, not necessarily its content, and different types of images can be dealt with in different ways.

Images which convey information

It should be fairly obvious which images are intended to convey information and which aren't. If you're unsure, imagine you're reading the page out to someone over the phone. Is the information in the image important enough for you to mention? If so, it's an information image, and needs an appropriate alt text. As an example, if you have a page of information about a company director, including a photograph, then that photograph is intended to give information (i.e., what he or she looks like), so can be given alt text of "Photograph of Joe Bloggs, Chief Executive".

Decorative images

An easy one this. Using the phone test - if it's just there to add some pretty to a page, then it doesn't need descriptive alt text. It can instead be given empty (alt=" "), or preferably, null (alt="") alt text. Null is preferable because empty will show up a tiny yellow tooltip. Alternatively, you can remove the image from the HTML entirely, and display it as a background image using CSS. This should never be done for information images.

Functional images

Does exactly what it says on the tin. Or at least, the alt text should. Functional image alt text needs to describe the function, not the look. Where an image is used as a link, this is usually the destination of the link (e.g., "Home", "About us"). Form submit buttons should state the purpose (e.g., "Search now", "Go", "Cancel", etc.). If you're using your logo to link to your home page (or someone else's), then you don't need the word "logo". Your alt text could simply be "Organisation home" (if it's on your site), or just "Organisation" if it's someone else's.

Images of text

Should be avoided, where possible, in favour of actual text, but where you have to use them, the alt text is easy - just repeat the text that's displayed in the image. Layout images
Now that CSS is gaining popularity and browser support, these should be a thing of the past, but if you've got spacer gifs or images which are only there to help you with the layout, try and keep them to a minimum, and make sure they have null or empty alt.

Structural images

These should also be replaced with appropriate HTML or CSS, but if you must, then make sure they have alt which correctly reflects the structural nature of the image, rather than what it looks like (e.g., "bullet" or "item", or even "*" for a list bullet graphic).

Complex images

If you've got charts or graphs, or anything more complicated than can be summed up in a few words, then alt isn't really going to do it for you and you'll need a longer description. You still need to give the image appropriate alt text though, and this can be as simple as "Graph showing the steady growth in share prices over the past five years". For the longer description, this can be presented in several ways, the easiest and most logical of which is in accompany text on the same page. If you can't do that, a link to a longer description can be given, again, preferably adjacent to the image it relates to.

Image maps

The main image used for the image map needs alt text, as well as each AREA element. The alt for the main image could be something like "Map of wards in x district", and, perhaps obviously, the alts for the AREA element should follow the rules for functional images given above. If in doubt, step back and think about what the purpose of the image is, and remember, keep it concise.



Comments (7)

Tag: Better connected, better results

Posted at: 14/09/2007 9:27 AM by Dave Wailing

Thank you

Philippe said:

Thank you for a very clear explanation of how to fill the alt attribute. I'll translate it into French for my readers and clients.

Posted at: 16/7/2010 11:22 AM by Dave Wailing

Joe Bloggs's picture

JackP said:

Assuming that the fact that Joe Bloggs was Director was already listed in the text of that page, would you still read out over the phone that there was a photo of him?

After all the additional image conveyed - what he looks like - isn't conveyed by saying "here's a picture of Joe Bloggs".

You'd need to add "he's wearing glasses, he's got dark hair and bushy eyebrows and..." by which time your listener would be telling you that they really don't care.

Surely if the text indicates elsewhere that Joe Bloggs is a director, then this sort of image is bordering on decorative?

And "space" alt text will only show up as a tiny yellow tooltip if you're using internet explorer (I know that could be inferred from what went before about IE, but thought it might be worth re-stating that this would only be IE)

Having said that, I agree wholeheartedly on the rest of it, but you'd already know you were preaching to the converted with me anyway!

Posted at: 16/7/2010 11:24 AM by Dave Wailing

Alt text with pictures

Richard Morton said:

JackP has beaten me to it, I would definitely not recommend alt text for a picture of someone unless: 1) The name/title is text within the image, in which case the normal rules apply, or 2) There is IMPORTANT information conveyed within the image that is not conveyed elswhere on the page. In the vast majority of cases this wouldn't apply but to set an example how about:

A picture of Patrick Moore with a chart showing planets behind him, and him pointing to Jupiter. If the fact that he is pointing to Jupiter rather than another planet is important to the understanding of the page then that should definitely be conveyed within a text equivalent.

Posted at: 16/7/2010 11:25 AM by Dave Wailing

Tooltips with IE

Jonathan Davies:

"The purpose of alt is not to display a tooltip. Microsoft, in their wisdom, decided that this would be a nice feature, and implemented it in Internet Explorer. Firefox, and other browsers which implement the spec as it was intended, correctly don't display alt as a tooltip."

For reference: To implement a tool tip you should officially be using the title attribute. This is valid and is picked up in all browsers - not just IE. If you want to include tooltips, most images would require both an alt attribute and a title attribute. Sometimes this is the same text for each, but often it's not, as tooltips and alt attributes clearly have very distinct functions.

Typically, Microsoft doesn't follow the rules correctly with alt, but thankfully it does implement title attributes correctly where they are present. For example, giving an image an empty title attribute will override the default use of alt text for tooltips in IE. That way, not even the "tiny yellow tooltip" referred to above would appear for images with an empty alt attribute.

For purely decorational images therefore you could use a blank alt attribute AND a blank title attribute to ensure it's accessible, valid and also IE-friendly.

Of course you should ideally be supplying purely decorative images within the CSS anyway. Here, naturally, images do not need alt or title text.

Hopefully that helps clear up an oft-overlooked IE irregularity.

Posted at: 16/7/2010 11:26 AM by Dave Wailing

SEO

TDRose said:

How does Search Engine Optimization (SEO) play into this "alt" and "title" tag discussion?

Posted at: 16/7/2010 11:27 AM by Dave Wailing

Accessible Flash banner ad guidelines

Web Access Centre Blog said:

[...] When choosing the Name or Description follow the same rules that apply for alt text. As Flash banner adverts generally link to other pages or sites, ensure that the user will understand where the link will lead. Avoid redundant link text such as "Link to…", "Click here to…", "Image of…" and so on. [...]

Posted at: 16/7/2010 11:29 AM by Dave Wailing

Images and Dragon

Pat Rees said:

For image links, it is important that the alt attribute exactly match the image text. Someone using Dragon Naturally Speaking to navigate a page (no keyboard, no mouse) will try to activate the link by speaking the words that they see. If the image text doesn't match the alt attribute Dragon will not find it. Then they have to get to that link by breaking the page into smaller and smaller quadrants to focus on the link, a much more time consuming process. Use the title attribute if you want to further describe the purpose of the image link.

Posted at: 16/7/2010 11:33 AM by Dave Wailing

Add a comment

If you would like to add a comment, you need to login first.