I'm looking for some CSS guru advice on best structure. I'm implementing sprites instead of icons on a horizontal 'list'. Current html is like :
<a href="link"><img src="icon" /></a><a href="link_b"><img src="icon"/></a>
etc.
So I replace with a sprite. I'm using
<a href="link" class="sprite_img_a"></a><a href="link_b" class="sprite_img_b"></a>
but to do this I give the tag inline-block and width. I've never liked inline-block and it seems clunky.
Are there better options ? (nested span, div wrapper ?)
I like your techniques @sandeep and @hatake-kakashi. A couple possible improvements (though maybe beyond the scope of the question). Try structuring your list and html as such:
This way, the cascade works for you and all links in this list can get the sprite styling without redundant class names. And you let your parent elements handle the positioning. At least, I think that's correct. Apologies for syntax and pseudo-code as I wrote it kinda quick and dirty.
I usually do like this:
Here is the css:
@karishma:
inline-block
is a good option but if don't want it so, you can use the CSS below.It's good to use icon image in background because 1) it saves markup space & 2) it's good for SEO purposes to avoid unwanted images caches by Google.