When the heading text and link destination are the same, these discussions do not provide enough evidence to show that either nesting order is better for SEO. Several respondents consider both a link inside a heading and a heading inside a link acceptable in the HTML5 example, with the same SEO effect. However, that is their assessment, not the result of a ranking experiment. In practice, start by checking the HTML version, the content the link should cover, and maintenance needs. Restrictions from older versions of HTML should not be applied to every situation.
Check the HTML version first: passing validation does not mean better rankings
The two structures in question are:
- A link inside a heading: <h1><a href=””>xyz</a></h1>.
- A heading inside a link: <a href=””><h1>xyz</h1></a>.
One participant initially said that only the first structure was correct, while subsequent comments clarified that both are acceptable in HTML5. Another respondent explicitly noted that, if HTML 4.01 validation is required, the second structure produces an error stating that H1 is not allowed in that position. To judge whether a structure is valid, first check the HTML version.
Failing validation does not necessarily cause rankings to drop. One respondent considered invalid markup harmful to SEO but also said that a single issue would have a limited impact. They provided no quantifiable ranking evidence.
The real disagreement concerns what the link covers, not simply the nesting order
Not all respondents considered the two structures entirely equivalent. One answer argued that block-level links should be avoided for SEO because anchor text—the link text—needs to be clear so that Google can understand a link’s relevance. However, the statement it quoted from John Mueller was narrower: Google can recognize links used this way and treat their text as anchor text. His caution was against routinely using an entire paragraph as the anchor text for every internal link.
This quotation does not directly support the conclusion that putting a heading inside a link harms SEO. Both structures in the example use only “xyz” as the link text. Wrapping both a heading and an entire summary paragraph in a link would raise a separate issue: expanding the text included in the link. The quotation in the discussion should not be treated as a verified, current official rule.
When only the heading needs a link, ease of maintenance can guide the choice
When only a heading needs a link, as in the example, putting the link inside the heading is a reasonable default. There is no need to frame that choice as an SEO benefit. One respondent preferred placing h1 on the outside because it makes headings easier to find when scanning the source code. Another recommended the same structure based on traditional markup conventions.
If you choose to put the heading inside the link instead, these discussions provide no basis for ruling out the HTML5 usage shown in the example. One participant reported an alignment issue but acknowledged that CSS margin settings might have caused it. That does not establish that the nesting order itself is problematic. Rather than rewriting markup for an unproven ranking difference, first check the HTML version and the content that should be linked.
Heading link markup: perspectives from across the web
Do the two structures have different clickable areas?
One respondent noted that, in the HTML5 example presented, only the link text is clickable when the link is inside the heading, whereas the entire heading row is clickable when the heading is inside the link. If the link text and destination are the same in both cases, the choice can therefore be based on the desired clickable area, without treating this interface difference as evidence that either structure is better for SEO.
References
- Anchor tag inside <h1> or <h1> inside anchor tag: which is better?webmasters.stackexchange.com — Source used in the article above.
- Anchor tag inside <h1> or <h1> inside anchor tag: which is better?webmasters.stackexchange.com — Source used in the article above.
- Anchor tag inside <h1> or <h1> inside anchor tag: which is better?webmasters.stackexchange.com — Source used in the article above.
- Anchor tag inside <h1> or <h1> inside anchor tag: which is better?webmasters.stackexchange.com — Source used in the article above.
- Anchor tag inside <h1> or <h1> inside anchor tag: which is better?webmasters.stackexchange.com — Source used in the article above.
- Anchor tag inside <h1> or <h1> inside anchor tag: which is better?webmasters.stackexchange.com — Discusses: Do the two structures have different clickable areas?
- Anchor tag inside <h1> or <h1> inside anchor tag: which is better?webmasters.stackexchange.com — Source used in the article above.
- Anchor tag inside <h1> or <h1> inside anchor tag: which is better?webmasters.stackexchange.com — Source used in the article above.

