css sprites: which html element using for background-position?
I am wondering for using css sprites which tag html is best?
I mean i can use
< img src="trasparent.png" sty开发者_开发百科le="background-position:ecc"> or ?
I saw Google using < span> for the "o" of G"o o o o o"gle
thanks
You can use almost any element you like.
One thing to note though is that elements like <span>
and <a>
are inline elements. Thus if you try and add dimensions to them to match the size of your background sprite, these dimensions will be ignored. To fix this you can use things like line-heights or padding to set dimensions, or you could change the element into a block level element using the CSS: display:block
.
Another rule that will allow dimensions to be added is display:inline-block
, but this can cause a few issues in IE6 and earlier browsers.
Google is actually using a span, in my experience is a good choice too.
精彩评论