JavaScript
Article
By Simon Willison

Blank alt attributes

By Simon Willison
Last chance to win! You'll get a... FREE 6-Month Subscription to SitePoint Premium Plus you'll go in the draw to WIN a new Macbook SitePoint 2017 Survey Yes, let's Do this It only takes 5 min

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.

--ADVERTISEMENT--

Login or Create Account to Comment
Login Create Account
Recommended
Sponsors
Get the most important and interesting stories in tech. Straight to your inbox, daily.Is it good?