I would like to remove the text in a link and replace it with an image using css.
Markup:
<a id="notifications" href="#">Notifications</a>
Css:
#notifications{
background: url('http://icons.iconarchive.com/icons/treetog/i/16/Floppy-Small-icon.png') no-repeat;
height: 16px;
width: 16px;
text-indent: -9999px;
overflow: hidden;
}
I have tried all sorts of things, but can’t seem to get rid of the text. Is this something that is not doable with css?
As minaz pointed out,
display: blockwill solve the issue. These other properties will also get your<a>, which is adisplay: inlineelement by default, to respect thetext-indentproperty:The W3 spec on text-indent explains why: