?

Log in

No account? Create an account

Previous Entry | Next Entry

Valid XHTML 1.0

Want to make an entire <div> into a link and still have your XHTML 1.0 document validate? Try this:
<a href="http://corknut.org"><ins><div> div contents go here </div></ins></a>


Because while <div> isn't allowed inside <a>, it is allowed inside <ins>, which in turn is allowed inside <a>. And it validates! How ridiculous.

Then make sure the div's style uses cursor: hand; so that it looks like a link to the visitor.

(Thanks to okb for figuring this out for me.)

Edit: Okay, better solution: <span> is allowed inside an <a>, and with the display: block; style it works the same as a <div>. So that's what I ended up using.

Comments

( 6 comments — Leave a comment )
mskala
Jul. 13th, 2004 01:02 pm (UTC)
Can't you put the <a> inside the <div> instead of the other way around?
rfreebern
Jul. 13th, 2004 02:38 pm (UTC)
That doesn't turn the entire <div> into a link, just the contents.
myhelmet
Jul. 13th, 2004 01:28 pm (UTC)
Nice trick. Thanks for posting it!
katre50
Jul. 13th, 2004 03:13 pm (UTC)
I'd just like to mention that I think "cursor: hand" is the worst thing ever. Thanks.
okb
Jul. 13th, 2004 07:29 pm (UTC)
I cannot believe that the spec is set up this way. Allowing <span style="display: block"> and disallowing <div> is the height of absurdity.
dreatastespie
Jul. 13th, 2004 08:46 pm (UTC)
I have no idea what you are talking about at all.

:P
( 6 comments — Leave a comment )

Latest Month

February 2011
S M T W T F S
  12345
6789101112
13141516171819
20212223242526
2728     
Powered by LiveJournal.com