Friday, March 12, 2010

How to use a CSS background image as a hyperlink

This snippit of HTML and CSS will let you use a background image in CSS and use it as a hyperlink in HTML. Here’s the code.

HTML Code:

<a id="test" href="http://yourlink.com">This will get moved off screen</a>

CSS:

a#test{
display:block;
width:100px;
height: 50px;
background: url(images/yourimage.jpg) no-repeat;
text-indent: -9999px;
}

Many thanks to R1gM for this.

No related posts.


Leave a Reply