hail2u / html-best-practices

For writing maintainable and scalable HTML documents
4.11k stars 439 forks source link

Making the `h1` and `p` as the child of the anchor tag is not valid HTML #73

Closed vanzasetia closed 2 years ago

vanzasetia commented 2 years ago

The HTML code snippet inside the Don’t split same link that can be grouped section, specifically the Good one, shows that wrapping the h1 and p tag inside an anchor tag.

<a href="https://whatwg.org/">
  <h1>WHATWG</h1>

  <p>A community maintaining and evolving HTML since 2004.</p>
</a>

It could be essentially an invalid HTML according to Can I Include site.

hail2u commented 2 years ago

a element content model is:

Transparent, but there must be no interactive content descendant, a element descendant, or descendant with the tabindex attribute specified.

<a><p>text <a>link</a> text</p></a> is invalid, but <a><p>text text text</p></a> is valid.