I have been working with a lot of html
structuring lately and I started to wonder what are the elements that are allowed as children of an <a>
element?

- 7,968
- 16
- 57
- 91
-
http://stackoverflow.com/questions/18289583/is-it-legal-to-have-children-of-an-anchor-tag-a-in-html – Robban64 Apr 14 '14 at 11:47
-
1You can always test what's valid and what's not http://validator.w3.org/#validate_by_input – Scott Apr 14 '14 at 11:52
2 Answers
Anything as long as there insn't any interactive content like buttons, forms, other link...
w3.org HTML5 specs :
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).
see link to source
And here is an example of what you can do (still form w3.org) :
<aside class="advertising">
<h1>Advertising</h1>
<a href="http://ad.example.com/?adid=1929&pubid=1422">
<section>
<h1>Mellblomatic 9000!</h1>
<p>Turn all your widgets into mellbloms!</p>
<p>Only $9.99 plus shipping and handling.</p>
</section>
</a>
<a href="http://ad.example.com/?adid=375&pubid=1422">
<section>
<h1>The Mellblom Browser</h1>
<p>Web browsing at the speed of light.</p>
<p>No other browser goes faster!</p>
</section>
</a>
</aside>

- 99,765
- 32
- 217
- 249
Changes in HTML5
Although previous versions of HTML restricted the a element to only containing phrasing content (essentially, what was in previous versions referred to as “inline” content), the a element is now transparent; that is, an instance of the a element is now allowed to also contain flow content (essentially, what was in previous versions referred to as “block” content)—if the parent element of that instance of the a element is an element that is allowed to contain flow content.

- 1
- 1

- 2,679
- 2
- 26
- 44
-
-
2please don't copy answers form other posts (http://stackoverflow.com/a/18289616/1811992) – web-tiki Apr 14 '14 at 11:58