CSS – Hide Text and display a Image

Posted by on Jan 5, 2012 in CSS | 0 comments

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

468 ad

Leave a Reply