CSS – Hide Text and display a Image

Converting Plain Text

The CSS Code

span.image { 
background: url(/images/bamboo.jpg) no-repeat; /* url to image */ 
width:100px;  /* actual image width */
height:100px; /*actual image height */
text-decoration:none; 
display:block; 
font-size:0px;
} 

The Text in a span Tag

<span class="image">Replace this text with an image</span>

The Image

The Result

Replace this text with an image

Converting a Link

The CSS Code

a.image { 
background: url(/images/bamboo.jpg) no-repeat; /* url to image */ 
width:100px;  /* actual image width */
height:100px; /*actual image height */
text-decoration:none; 
display:block; 
font-size:0px;
} 

The Text in an anchor Tag (link)

<a href="#" class="image">Replace this text with an image</a>

The Image

The Result

Replace this text with an image

Posted in: CSS

Leave a Reply

Your email address will not be published. Required fields are marked *