Closed westonruter closed 14 years ago
The code you posted for wrapping a <a /> around <h1 /> is invalid HTML.
The correct way according to the standards is to do this:
<h1><a href="...">info</a></h1>
<p><a href="...">This is interesting.</a></p>
Actually, the whole point is that this construction is allowed in HTML5. And a HTML5 parser should create a DOM structure with an 'a' element as parent and 'h1' and 'p' as children.
"The a element may be wrapped around entire paragraphs, lists, tables, and so forth, even entire sections, so long as there is no interactive content within (e.g. buttons or other links). This example shows how this can be used to make an entire advertising block into a link:"
http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-a-element
I'm not sure if we should include this test in html5test.com. This construct is new to the HTML5 specification, but in this case the specification follows common behavior. Browsers already allow a as a block level element and all browsers would pass this this.
westonruter, I stand corrected! Thank you for the link. HTML 5 has some nicer surprises in store :-)
Another useful Parsing rules test would be whether an <a> element can wrap block elements.
Old HTML parsers may parse this as: