Level-one heading in document required

Warn if there is no h1 element in the document.

This rule is based on Techniques H42 for Success Criterion 1.3.1 in WCAG, Practices for skipping heading level and Web Accessibility Tutorials - Headings.

Rule Details

👎 Examples of incorrect code for this rule

<html>
    <head>
        <title>page</title>
    </head>
    <body>
        <main>
            <p>text</p>
        </main>
    </body>
</html>

👍 Examples of correct code for this rule

<html>
    <head>
        <title>page</title>
    </head>
    <body>
        <main>
            <h1>heading</h1>
            <p>text</p>
        </main>
    </body>
</html>

Setting value

{
    "rules": {
        "required-h1": true
    }
}
{
    "rules": {
        "required-h1": {
            "option": {
                "expected-once": true,
                "in-document-fragment": true
            }
        }
    }
}
  • Type: boolean
  • Optional
  • Default value: true

Options

expected-once

Warn if there is a duplicate h1 tag in the document.

  • Type: boolean
  • Optional
  • Default value: true

in-document-fragment

Set it to true if you want this rule to apply within document fragment rather than the entire document.

  • Type: boolean
  • Optional
  • Default value: false

Default severity

error