CSS | Image Sprites
It is basically an image which is a collection of different images put together to form a single image. The use of image sprites is done for two main reasons:
- For faster page loading since use only single image.
- It reduce the bandwidth used to load multiple images. This way less data is consume.
Image sprites are generally used for designing a graphic social media bar or a navigation bar to make it more attractive and efficient at the same time. It is just a method in HTML and CSS to implement more efficient way of putting images and designing web pages.
Used Image:
![]()
Example:
<!DOCTYPE html> <html> <head> <style> #navlist { position: relative; } #navlist li { margin: 0; padding: 0; list-style: none; position: absolute; top: 0; } #navlist li, #navlist a { height: 100px; display: block; } .gfg { width: 100px; left:0px; background: url( } .gfg1 { width: 100px; left:120px; background: url( } .gfg2 { width: 100px; left:240px; background: url( 'https://cdncontribute.geeksforgeeks.org/wp-content/uploads/icon.png') -300px -140px; } </style> </head> <body> <ul id="navlist"> <li class = "gfg"><a href="#"></a></li> <li class = "gfg1"><a href="#"></a></li> <li class = "gfg2"><a href="#"></a></li> </ul> </body> </html> |
Output:

Recommended Posts:
- Convert an image into grayscale image using HTML/CSS
- Saving an Image from URL in PHP
- CSS | Image Gallery
- How to get the width and height of an image ?
- CSS | background-image Property
- HTML | DOM Image Object
- Set the size of background image using CSS ?
- How to change color of PNG image using CSS?
- jQuery | :image Selector
- Drop shadow for PNG image using CSS
- Resize image proportionally with CSS
- CSS | border-image Property
- HTML | Mapping Image
- HTML | DOM image naturalHeight property
- HTML | DOM image naturalWidth property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




