www.webdeveloper.com
Results 1 to 3 of 3

Thread: CSS sprites and http-requests

  1. #1
    Join Date
    Nov 2010
    Posts
    2

    CSS sprites and http-requests

    I think I understand the basic idea of CSS sprites: A given rollover only needs to http-request a single image for both states. But what about situations where there are multiple elements all specifying the same background image? For example:

    Code:
    #element1
    {
        background-image: url("spritesheet.png");
    }
    
    #element2
    {
        background-image: url("spritesheet.png");
    }
    Will this generate two http-requests (one for each element), or are browsers smart enough to cache spritesheet.png locally? I ask because I'd like to use CSS sprites to create a big image map by specifying the same master spritesheet as the background image of each (li a) in a ul, changing background-position for (li a:hover), but obviously this wouldn't be viable if each (li a) results in a separate http-request.

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    1 request, the image will be cached.
    At least 98% of internet users' DNA is identical to that of chimpanzees

  3. #3
    Join Date
    Nov 2010
    Posts
    2
    Quote Originally Posted by Fang View Post
    1 request, the image will be cached.
    Cool, thanks!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles