CSS Image Sprites

CSS Image Sprites

Introduction to CSS Image Sprites

Image sprites are a way to reduce the number of HTTP requests by combining multiple images into one file and displaying parts of it as needed.

Using Image Sprites

Example


.icon {
    background-image: url('sprite.png');
    width: 50px;
    height: 50px;
}
.icon-home {
    background-position: 0 0;
}
.icon-search {
    background-position: -50px 0;
}
        

Browser Support

Supported by all major browsers.