It is not possible in HTML, since an a
element inside an a
element is not allowed. By existing HTML specs, you cannot have e.g, div
inside a
either, but this restriction was never really enforced by browsers and it has been lifted in HTML5 drafts. Nested a
elements are a different issue, since it would create an active area inside an active, and its meaning would need to be defined and it would be confusing.
What happens in practice when using
<a href=foo>bla bla <a href=bar>inner link</a> stuff</a>
is that it works the way you want except that content of the outer a
element after the inner a
element is not a link at all. Apparently browsers are not prepared to handling constructs like this. Effectively, they imply a closing </a>
tag when they encounter an <a>
tag when an a
element is open. Much like they do for p
elements.
So an inner link at the end of a link would sort-of work. There is of course no guarantee that it will keep working in future versions of browsers, or that it works on all browsers.
You could use two separate, non-nested a
elements in succession and to place the second one visually inside the first one, using CSS positioning. But this would get somewhat complicated. A much simpler approach is to set up a JavaScript pseudo-link:
<span onclick="document.location.href = 'foo'; return false">inner link</span>
The downside is that it won’t act in a link-like manner when JavaScript is disabled, and search engines won’t treat it as a link either.