Skip to main content

HTML Guide

The element “a” must not appear as a descendant of the “a” element.

An <a> element (anchor) cannot be nested inside another <a> element.

Nesting anchor elements is invalid HTML according to the W3C and WHATWG specifications. Only phrasing content (such as text, images, or spans) is allowed inside an <a>. Placing an <a> inside another <a> can confuse assistive technology and browsers, leading to unpredictable behavior and accessibility issues.

Incorrect example:

<a href="https://example.com">
  Visit <a href="https://another.com">Another Site</a>
</a>

Correct usage: Separate the anchor elements so they do not overlap.

<p>
  Visit <a href="https://example.com">Example Site</a> 
  and 
  <a href="https://another.com">Another Site</a>
</p>

Full minimal HTML example:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>No Nested Anchors</title>
  </head>
  <body>
    <p>
      Check <a href="https://site1.com">Site 1</a> or 
      <a href="https://site2.com">Site 2</a> for more information.
    </p>
  </body>
</html>

Always ensure anchor tags are not placed inside other anchor tags to maintain valid and accessible HTML.

Learn more:

Related W3C validator issues