JavaScript - - By Simon Willison

Blank alt attributes

Roger Johansson has a published a short discussion of the alt and title attributes for images. One point he mentions that I think deserves emphasis is the importance of the blank alt attribute. When checking a page’s accessibility, many people attempt to add a descriptive alt attribute to every image on a page. This really isn’t necessary, and could in fact harm the accessibility of the page! On most sites, many of the images on the page exist for purely decorative purposes; the content would still make perfect sense if the images were removed. These images should have a blank alt attribute, to prevent their display in text or speech browsers.

A pleasant side-effect of moving to CSS based web design is that decorative images tend to end up as CSS background images, rather than inline images in the document. This is certainly the preferred approach, but if a decorative image needs to be included inline but makes no contribution to the underlying content its alt attribute should be left blank. My piece on Writing good ALT text has further tips on this, one of the trickier aspects of web accessibility.

Sponsors