This article originally appeared as a Design and Usability Tactics e-newsletter.
By Michael Meadhra
Web page accessibility is a growing concern for many Web builders. Most large government and educational sites are required to meet accessibility standards to comply with the Americans with Disabilities Act (ADA). Although recent court rulings suggest that commercial sites may not be subject to the ADA, many larger sites mandate compliance with the World Wide Web Consortium's Web Content Accessibility Guidelines (WCAG) as well.
How alt attributes help accessibility
The first, and arguably most important, of the WCAG checkpoints deals with providing a text equivalent for every nontext element on a Web page. Since the guidelines mention the alt attribute specifically, most Web builders interpret the guideline to mean that an alt attribute is required for every image or other nontext page element. The alt attribute isn't the only way to meet the text equivalency requirement, but it's the simplest and easiest to implement in many cases.
By including an alt attribute in each IMG tag, you enable visually impaired visitors who use screen readers to "hear" the content that other visitors see in the images. However, to perform that task properly, the text of the alt attribute must be functionally equivalent to the image or other nontext element it's replacing.
Making alt attributes functionally equivalent
Many Web builders encounter problems when crafting the text of an alt attribute so it successfully conveys the same meaning as the corresponding image. Putting the image filename or other cryptic text in the alt attribute doesn't cut it. That tactic may enable your page to pass muster with an automated accessibility validator (e.g., Bobby) that simply checks for the existence of the alt attribute but doesn't actually make your Web page more accessible.
The alt attribute text should answer the question, "What function does this image serve?" in such a way that someone reading the text will get essentially the same meaning as someone viewing the image.
This doesn't mean that you need to describe the image in detail. The goal of the alt text is to state the purpose of the image, not translate its entire content from a visual format to a textural one. If you need to compose a long text description of an image, put the description in a separate text file and use the longdesc attribute to reference that file.
Consider the following examples:
The third example assumes there is a text description of the poison ivy plant elsewhere on the page. If the photo is the only information presented that enables the visitor to identify the plant, then you may need a longer text equivalent. The longdesc attribute, pointing to a separate text file, is the way to handle such a situation.
Empty alt attributes
The last two examples show empty alt text attributes. The images to which these attributes are attached may be necessary to the appearance and visual organization of the page, but they are not part of the essential page content. Consequently, there's no function for which you need to provide a text equivalent.
However, the absence of a function doesn't mean that you can omit the alt attribute. Providing an empty alt attribute efficiently tells screen readers to ignore this image, whereas a missing alt attribute may cause the screen reader to compensate for the omission by reading the path and filename aloud.
Michael Meadhra has been working in the IT field since the earliest days of the Web. His book credits span some three dozen titles, including How to Do Everything with Dreamweaver MX.