CSS Sprites

An early CSS technique to improve site performance and maintainability by bundling multiple image assets into a single sheet

Sprite map of various navigation and UI elements on amazon.com

There was an era from roughly 2002 to 2007 where adoption of new W3C recommendations had stalled in leading browsers, leading to stagnation in web capabilities.

During that time development of CSS techniques (and even hacks) that added new capabilities to the toolkit fell to web developers instead and became a necessary way of making progress. Many of these were named and published, and if you were around at the time names like Tantek’s box model hack, Fahrner Image Replacement, or Sliding Doors should tug at the nostalgia.

My contribution was CSS Sprites, a way of replacing HTML elements with imagery during rendering to allow for more visual interactions, including bitmapped imagery and rendered type. It also had the benefit of combining multiple image resources as a single sheet that reduced the number of assets needed to load, deferring the job of slicing and reassembling just the relevant pieces for each element to the CSS layer.

The technique allowed not only visual improvements but also a big boost to performance that led Sprites to live on for many years, allowing web authors to ship more interesting sites that were highly performant until browser support for the latest standards caught up.

CSS Sprites were adopted by many top sites of the era, including the Amazon and White House examples shown.

  • Sscreenshot of whitehouse.gov asset, showing the site's primary navigation rendered as a sprite map
Top