Reputation: 2039
I want to replace the text of a url to an image. I am trying following:
HTML:
<div class="img">
<a href="#">link</a>
</div>
CSS:
.img a{
width: 96px;
height: 96px;
background: url("image.jpg");
text-indent: -9999px;
}
It would still show the text. I want the image instead of the text.
PS. I don't want to put the image in the html, ie.
<div class="img">
<a href="#"><img src="image.jpg" alt="image" /></a>
</div>
Upvotes: 0
Views: 1209
Reputation: 1774
I don't know the exact CSS trick that you should use to get this done.
But as per my knowledge I can make a suggestion.
You cannot have class name as "img" as it is already a HTMl tag.
If you write anything for it, that property will be considered for the <img>
tag.
Upvotes: 0
Reputation: 67194
An anchor tag is by definition an inline element and therefore will not accept height or width declarations.
To obtain your desired effect, use display: inline-block;
. (won't work in IE<8 I believe)
.img a{
display: inline-block;
width: 96px;
height: 96px;
background: url("image.jpg");
text-indent: -9999px;
}
Upvotes: 1
Reputation: 9172
text-indent
applies to block level elements so just add display: block;
or display: inline-block;
to the .img a
CSS (this will also make the width
and the height
work).
Upvotes: 0