I want to replace anchor text with image using CSS. Here is my code.
HTML
<div id ="first">
<a href="#">Read More</a>
</div>
<div id ="second">
<a href="#">Read More</a>
</div>
CSS
#first #second a{
background:url(../images/layout/tab.png);
float:right;
}
Here is JsFiddle link http://jsfiddle.net/chhantyal/GDF9K/
Why is it not working? What’s the right way?
Your selector isn’t doing what you expect it to. Your current selector matches this structure:
You have to be verbose:
Demo: http://jsfiddle.net/GDF9K/2/
But if since you asked for the right way, I suggest you use a class:
And your CSS becomes: