Introduction
Using image sprites you can divide the portion of one image into other small images. Every single image works standalone. In simple terms, you can say one image is a collection of other small images.
The main benefit of using image sprites is that it reduces the HTTP request and size of an image (see the following figures).
If your web page has many images then it will take more time to load your web page on the server and also generate multiple HTTP requests. But when image sprites are used it take less time to load page as well as take less time to generate HTTP server requests.
Code:
HTMLPage.htm
- <!DOCTYPE html>
- <html>
- <head>
- <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
- <title></title>
- </head>
- <body>
- <div class="firstmain">
- <ul id="FirstUL">
- <li id="first"><a href="white.htm"></a></li>
- <li>
- <div id="second">
- <a href="blue.htm"></a>
- </div>
- </li>
-
- </ul>
- <ul id="SecondUL">
- <li id="third"><a href="red.htm"></a></li>
- <li id="forth"><a href=yellow.htm></a></li>
- </ul>
- </div>
- <div class="secondmain" >
- <a class="fifth" href="green.htm"></a>
- </div>
- </body>
- </html>
StyleSheet.css
Output
Internet Explorer
Chrome
Fire Fox
Safari
When you click on the red ball you will be navigated to the
Red.htm page.
Output