Topic: Making div as link

   I have a div containing image in it and I want to make that div act as link. I have done it using

<a href="#"><div></div></a>

but it create problem in html validation.

So, Is there any other way to do it.


Re: Making div as link

DIVs do not belong inside links.

The easiest thing to do is:

<a href="#"><img src="path/to/image.jpg" alt="Make sure alt is here if you are using strict" /></a>

However, if you are using CSS to place a background, first do:

<a id="whatever" href="#">Random Text to Describe Image</a>

Then in your CSS:
a#whatever {
    background: url(path/to/image.jpg) no-repeat;
    height: 45px; /*insert your image height here*/
    width: 66px; /*insert your image width here*/
    text-indent: -9999px /*Makes text invisible to show only image */

Last edited by pimpmaster (2007-05-09 07:13:07)