Image sprites are a performance technique where multiple small images (icons, buttons, states) are combined into a single image file. Instead of downloading many separate images, the browser downloads one sprite sheet and CSS is used to display just the part we need with background-position.
In this navigation example, the sprite image from W3Schools (img_navsprites.gif) contains three icons — home, previous, and next — each with a hover state in the same file.
img_navsprites.gif.The background position changes vertically to reveal the hover version of each icon.
/* Normal & hover positions from the sprite sheet */
#home a { background-position: 0 0; }
#home a:hover { background-position: 0 -44px; }
#prev a { background-position: -47px 0; }
#prev a:hover { background-position: -47px -44px; }
#next a { background-position: -91px 0; }
#next a:hover { background-position: -91px -44px; }
<!-- Sprite-based navigation list -->
<ul id="navlist">
<li id="home"><a href="#" aria-label="Home"></a></li>
<li id="prev"><a href="#" aria-label="Previous"></a></li>
<li id="next"><a href="#" aria-label="Next"></a></li>
</ul>
Hover each icon below to see the sprite shift vertically.
background-position.width and height for the elements using sprites.background-position to show each icon in a navigation list.