How to get anchor label on div background image?
HTML:
<div id="facey"> <a href="http://www.facebook.com.au"></a> </div> CSS
#facey { float: left; width: 32px; height: 32px; background: url(file:///C|/Users/User/Documents/TAFE%20-%20Web/ICAWEB411A%20Design%20simple%20web%20page%20layouts/testing%20color/icons/facey%20sprite.png) no-repeat 0 0; } #facey:hover { background-position: 0 -32px; } I have a css sprite for social media icons, and I'm trying to put anchor tags on them to go to the corresponding websites, and I'm not sure how this works because the sprite images are used as background images and an anchor The tag doesn't seem to work for me inside the div? I'm not sure what I'm doing wrong here?
+4
3 answers
Put the background on the anchor, not on the div, this is an anchor tag that you can click at the end. Here the div is really completely redundant.
<a href="http://www.facebook.com.au" id="facey"></a> a#facey { float: left; width:32px; height: 32px; display: block; background:url(file:///C|/Users/User/Documents/TAFE%20-%20Web/ICAWEB411A%20Design%20simple%20web%20page%20layouts/testing%20color/icons/facey%20sprite.png) no-repeat 0 0; } a#facey:hover { background-position:0 -32px; } +1