Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What elements can be contained within a <a> tag?

What are the valid html elements, if any, that can be contained within a <a> tag?

like image 827
Ahmad Avatar asked Jul 31 '10 18:07

Ahmad


People also ask

Can an A tag contain a div?

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.

What are the 3 parts of a HTML tag?

An HTML element is defined by a start tag, some content, and an end tag.

What are tag elements in HTML?

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.


2 Answers

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

like image 149
Aya Avatar answered Oct 11 '22 12:10

Aya


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.

like image 31
meder omuraliev Avatar answered Oct 11 '22 11:10

meder omuraliev