Click to See Complete Forum and Search --> : Linking a whole div tag


The_Wanderer
12-28-2006, 08:33 PM
How would I go about linking a whole <div> tag? That is, how would I make it so that if I were to click anywhere within a div tag, it would act as a link.

thanks!
-The_Wanderer

Charles
12-28-2006, 08:35 PM
You style the A so that it is the same size as the DIV.

The_Wanderer
12-28-2006, 08:38 PM
How do you mean? Like this:
<a href='lookatme-im-a-link.php'><div> blah blah blah </div> </a>

sticks464
12-28-2006, 08:38 PM
I've never tried this but could possibly work:
<div><a href="somelink">content</a></div>

The_Wanderer
12-28-2006, 08:45 PM
Naw, that would just like the txt 'content' and nothing else. But thanks any way ;)

felgall
12-28-2006, 08:46 PM
The <a> has to go inside the <div> for the HTML to be valid. You then use CSS to make the <a> display:block and assign it the same dimensions as are assigned to the div that contains it. Make sure that the margins and padding on the <a> are set to 0 and it will then be exactly the same size as the <div> that contains it.

The_Wanderer
12-28-2006, 08:54 PM
Thank you very much!