A while ago, Eric Meyer suggested that HTML 5 should allow any element to turn into a link by taking an
href attribute – see his Any-Element Linking Demo. I suggested that, as a stop gap, HTML 5 should legalise the fact that all the big five browsers already allow the
a element to surround multiple elements and block level elements.
I’m delighted to report that my fellow Opera lovegod, Anne van Kesteren, tells me that HTML 5 now legalises this behaviour. So instead of coding a news “teaser” like this:
<h3><a href="story.htm">Bruce Lawson as Obama's running mate!</a></h3>
<a href="story.htm"><img src="bruce.jpg" alt="lovegod" /> </a>
<p><a href="story.htm">In answer to McCain's appointment of MILF, Sarah Palin, Obama hires DILF, Bruce Lawson, as his running mate. Read more!</a></p>
you can say:
<h3>Bruce Lawson as Obama's running mate!</h3>
<img src="bruce.jpg" alt="lovegod" />
<p>In answer to McCain's appointment of MILF, Sarah Palin, Obama hires DILF, Bruce Lawson, as his running mate. Read more!</p>
You can’t nest anchors (“there must be no interactive content descendant”) because that wouldn’t be compatible with current browsers.
2022 can’t come soon enough!
(Of course, you can do this now; that’s kind of the point with lots of the HTML 5 spec.)
Added 2 October: something’s missing
What I can’t believe I didn’t notice until today is that the HTML 5 spec doesn’t handle making rows in tables into links. Ironically, this was Eric’s original use-case—and the main feature of his demo. I noticed it when looking at the WHAT-WG‘s FAQs for something else.
Presumably, it’s not in the spec because it’s not backwardly compatible. Bugger.
(Last Updated on )
Buy "Calling For The Moon", my debut album of songs I wrote while living in Thailand, India, Turkey. (Only £2, on Bandcamp.)