I would like to reduce the number of HTTP requests in this website I'm building, and sprites would be a simple way to do that; however, for semantic reasons some of the imagery should remain in the foreground. Assume for the sake of this question that I have a perfectly functional way to sprite a foreground image.
So what should my alt tags look like? Here's one thought I had:
<img src="mysprite.png" alt="Product photographs of all the frobnobs we offer, organized by gauge">
…but does that really provide accessibility to the visually impaired, given that the image would only be showing one "frobnob" at a time?
position:absolute
and cropped (eitheroverflow:hidden
orclip
). I've managed to fulfill all the four points only if two same images are used next to each other - one for display, one for ALT text. It works but both the HTML and CSS look quite nasty though.content
property in a pseudo-element (:before
or:after
) but it is much worse in terms of performance when used on many elements on a large site.