Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it ok to have an `<a>` inside another `<a>`?

Tags:

html

If I had a link to another page, and another link was put inside it, would that be ok to do? Is it allowed in HTML5 and if so, which browsers support it?

Trying this in Chrome 14.0.835.202, I see the text on the left gets linked, followed by the #1 link, but the rest doesn't get linked.

Example:

<p>  <a href="download?file=2">Example file.txt</a>  [   <a href="revision?file=2&id=8">This is an example revision that fixes bug     <a href="bug?file=2&id=1">#1</a>.     Version number updated.   </a>  ] </p> 
like image 494
kirb Avatar asked Oct 23 '11 00:10

kirb


People also ask

Can you put tags inside of other tags?

You can't. It is explicitly forbidden by the HTML specification.

Can you have a inside a HTML?

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).


1 Answers

According to the W3C specification for links HTML5: No.

Content model:
Transparent, but there must be no interactive content descendant.

like image 137
zzzzBov Avatar answered Nov 09 '22 07:11

zzzzBov