What are the valid html elements, if any, that can be contained within a <a>
tag?
Nothing is wrong with placing a div inside a tag. In fact, you can place just about anything inside a tag as long as they are categorized as transparent , except that no descendant may be interactive content (eg: buttons or inputs) or an a element, and no descendant may have a specified tabindex attribute.
An HTML element is defined by a start tag, some content, and an end tag.
An HTML element is defined by a starting tag. If the element contains other content, it ends with a closing tag. For example, <p> is starting tag of a paragraph and </p> is closing tag of the same paragraph but <p>This is paragraph</p> is a paragraph element.
As of HTML 5, <a>
may contain not only (valid) inline elements, but also block elements, etc.
W3: http://dev.w3.org/html5/markup/a.html
Inline elements ( a, span, strong, em
among others ) can contain other inline elements and text nodes. An anchor can contain a span, which can contain a text node.
Generally, block-level elements may contain inline elements and other block-level elements. Generally, inline elements may contain only data and other inline elements. Inherent in this structural distinction is the idea that block elements create "larger" structures than inline elements.
From http://www.w3.org/TR/html401/struct/global.html
As noted in other answers, you can't nest an a
in an a
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With