Skip to content

Latest commit

 

History

History
37 lines (22 loc) · 1.18 KB

File metadata and controls

37 lines (22 loc) · 1.18 KB

Linter Rule: aria-level must be between 1 and 6

Rule: html-aria-level-must-be-valid

Description

Ensure that the value of the aria-level attribute is a valid heading level: an integer between 1 and 6. This attribute is used with role="heading" to indicate a heading level for non-semantic elements like <div> or <span>.

Rationale

The WAI-ARIA specification defines aria-level as an integer between 1 (highest/most important) and 6 (lowest/subheading). Any other value is invalid and may confuse screen readers or fail accessibility audits.

Examples

✅ Good

<div role="heading" aria-level="1">Main</div>
<div role="heading" aria-level="6">Footnote</div>

🚫 Bad

<div role="heading" aria-level="-1">Negative</div>

<div role="heading" aria-level="0">Main</div>

<div role="heading" aria-level="7">Too deep</div>

<div role="heading" aria-level="foo">Invalid</div>

References