/    Sign up×
Community /Pin to ProfileBookmark

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”);
}[/CODE]

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.

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@FangNov 22.2010 — 1 request, the image will be cached.
Copy linkTweet thisAlerts:
@HookflashauthorNov 22.2010 — 1 request, the image will be cached.[/QUOTE]

Cool, thanks!
×

Success!

Help @Hookflash spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...