To create accessible web pages, you need to mark up page elements with information for assistive technologies, such as screen readers. For example, each image on a page should be given a text equivalent, called alternative text (or alt text), which a screen reader conveys to users in place of the image.
Alternative text appears on the image placeholder while the image is downloading from the web; it also substitutes for graphics that fail to download. In some newer versions of browsers, the text appears next to the pointer as a ToolTip.
Adobe® Photoshop® software provides a web graphics production tool for developers to insert alternative text within the design tool itself. The Slice Options panel allows alternative text attributes to be assigned to each individual image slice. With the inclusion of alternative text, images can be interpreted by text-only assistive devices.
W3C reference: Alternative text for images
Adding alternative text to a slice or hotspot
To specify alternative text for a selected slice, either double-click the slice or right-click it and select Slice Options to access the Slice Options dialog box.
The alternative text can be added to the alt tag field.
The screen reader will announce the text in the alt tag field to describe the image to the user. Make sure that the alternative text correctly conveys the information contained in the image. If the image is decorative or irrelevant, the alt tag field can be left empty. This will cause an empty alt attribute to be added during export to HTML, which means that the screen reader will ignore the image.
Exporting HTML from Photoshop
When you export (by choosing File > Save for Web & Devices) or copy HTML from Photoshop, the following code and files are generated so that your Photoshop image can be re-created on a web page:
- One or more image files, depending on how many slices are in your document and how many states you include in buttons.
- A file called spacer.gif, if necessary, which is a transparent, 1-pixel-by-1-pixel GIF file that Photoshop uses to fix spacing problems when sliced images are reassembled in an HTML table. You can specify whether Photoshop exports a spacer. By default, Photoshop CS6 adds an empty alt attribute to spacer images and images that have no alternative text specified. This alerts screen readers that this image holds no content. The spacer image is therefore ignored, unless it is linked or clickable.
Selecting Edit Output Settings from the Save for Web & Devices dialog box brings up the Output Settings dialog box where you can tell Photoshop to always add the alt attribute to the image. If you specified a value in the alt tag field of the Slice Options window, that value will appear in the exported HTML code.
Adding alternative text in an external application
When an image created in Photoshop is used in a web environment, you must ensure that alternative text is applied in your web editing application. Adobe Dreamweaver® provides tools to do this. For more information, see the Dreamweaver CS6 accessibility overview.