Skip to main content

HTML Guide

Free site validation

Find out what web pages on your sites are affected by HTML issues.

Heading cannot be a child of another heading.

A heading element (h1, h2, h3, etc.) can’t be nested inside another heading element.

Here’s an example of invalid HTML code:

<h1>Main heading
  <h2>Sub heading</h2>
</h1>

To fix this issue, you should ensure that each heading element is properly nested within the document hierarchy. Headings should only be used to indicate the structure of your content, not to style it.

Here’s an example of valid HTML code that properly uses heading elements:

<main>
  <h1>Main heading</h1>
  <section>
    <h2>Section heading</h2>
    <p>Paragraph content</p>
  </section>
</main>

In this example, the heading elements are used to denote the structure of the document, with the h1 element indicating the highest level heading and the h2 element indicating a subheading within a section. Notice that in the valid example, each heading element is only used once and is not nested within another heading element.

Some times this can be caused by a typo in the end tag for a heading, for example:

<h3>Meet the Feebles<h3>

In order to fix this issue, the end tag should be </h3> in the example above.

Learn more:

Related W3C validator issues