Reputation: 20049
Ok, obviously if you have a lot if icons you generally load them in via a background image so you can utilise sprites; however, I was just wondering if there is any advantage to loading them in via the background versus loading them via a img
tag when it is just a single image?
Does the one in the CSS still make a http request for the image?
Upvotes: 0
Views: 39
Reputation: 4385
Sounds like you're mostly interested in how this affects performance. But since the question is open-ended here are other reasons, for completeness:
width: [something > 0]; height: 0; padding-bottom: [some]%
):hover
and you aren't using a sprite, for any number of reasons)background-size
or background-position
(IE > 8):before
and :after
, which are not supported for <img> (not required to be supported, anyway)Upvotes: 2
Reputation: 3966
Yes, it still makes a request, unless you URL encode the image, but this you can also do inline and is not necessarily more performant.
Upvotes: 1