SIA-R78Headings of same level have text content between them

Accessibility requirements

This rule is not required for conformance to any accessibility requirements.

Description

This rule checks that there is content between a heading and the next heading of the same or a lower level.

Applicability

This rule applies to every element in the HTML namespace with a semantic role of heading where the element is included in the accessibility tree.

Expectations

  1. There is some perceivable content located between the test target and either the first element in tree order which

or the end of the document, if no such element exists.

Assumptions

This rule makes no assumptions.

Accessibility support

This rule has the following accessibility support concern:

Examples

Passed

The headings in the following document all contain some content:

<html>
    <h1>Part one</h1>
    <!--
    No content is needed here. A subsection may start immediately at the beginning of a section.
    -->

    <h2>Chapter one</h2>
    <!--
    No content is needed here. A subsection may start immediately at the beginning of a section.
    -->

    <h3>Section one</h3>
    Since this is the smaller subdivision of the document, content is needed
    here. The immediate next heading has lower level. Without any content here,
    Section one would be a totally empty Section.

    <h1>Part two</h1>
    This is the beginning of Part two, with some preliminary content before its
    sections. This content is not strictly necessarily.

    <h2>Chapter one</h2>
    Content is needed here. The immediate next heading has the same level.
    Without any content here, Chapter one would be a totally empty Chapter.

    <h2>Chapter two</h2>
    <h3>Section one</h3>
    Since this is the end of the document, content is needed here. Otherwise,
    Section one would be totally empty. This content also serves as content for
    Chapter two since it has no heading of same or lower level after it.
</html>

The headings in the following document all contain some content:

<html>
    <h1>Part one</h1>
    <h2 aria-hidden="true">Chapter one</h2>
    <!-- This h2 is not included in the accessibility tree and therefore ignored by the rule -->
    <h2>Chapter two</h2>
    This serves as content both for Part one and Chapter two.
</html>

Failed

The headings for "Part two", "Part three" and "Chapter two" contain some content; the other headings in this document have no content:

<html>
    <h1>Part one</h1>
    <!--
    Part one is empty because there is no content between this and the start of Part two.
    -->

    <h1>Part two</h1>
    <!--
    Part two is not empty because the heading for Chapter one serves as content.
    -->

    <h2>Chapter one</h2>
    <!--
    Chapter one is empty because there is no content between this and the start of Part three.
    -->

    <h1>Part three</h1>
    <!--
    Part three is not empty because its subheadings serve as content.
    -->

    <h2>Chapter one</h2>
    <!--
    Chapter one is empty because there is no content between this and the start of Chapter two.
    -->

    <h2>Chapter two</h2>
    <!--
     Chapter two is not empty because the heading of Section one serves as content.
     -->
    <h3>Section one</h3>
    <!--
        Section one is empty because there is no content between this and the end of the document.
    -->
</html>

Inapplicable

This document contains no heading:

<html>
<main>
    Hello world
</main>
</html>