jsx-a11y/heading-has-content
Disallow empty headings — h1 through h6 must render accessible text content.
- Category: Accessibility
- Severity: warn
- Source:
oxlint-builtin:jsx-a11y - Framework: global
- Enabled when: always (unless customRulesOnly=true)
- Documentation: https://oxc.rs/docs/guide/usage/linter/rules/jsx_a11y/heading-has-content
Validation prompt
Use this to decide whether a fired diagnostic is real or a false positive.
Fires on <h1>-<h6> (and configured custom heading components) that render no children, or whose only children are aria-hidden / role='presentation'. dangerouslySetInnerHTML counts as content. False positive: the heading text comes from a child component the rule cannot statically inspect, e.g. <h1><Translate id='page.title' /></h1> where Translate emits text at runtime.
Fix prompt
Use this once validation confirms the diagnostic is real.
Render visible heading text inline (<h1>Create Account</h1>) or via a wrapper component that yields text content (<h1><Title /></h1>). Never use empty headings for spacing or styling — drop the heading or use a styled div instead. Don't aria-hide the only child. See https://oxc.rs/docs/guide/usage/linter/rules/jsx_a11y/heading-has-content
Related rules
More Accessibility rules from the rules reference:
jsx-a11y/html-has-lang: Require a lang attribute on the html element so screen readers use the right pronunciation rules.jsx-a11y/iframe-has-title: Require a unique, descriptive title attribute on iframes so assistive-tech users can identify embedded content.jsx-a11y/label-has-associated-control: Require every label to wrap its form control or point at one with htmlFor.jsx-a11y/no-autofocus: Disallow the autoFocus prop — stolen focus disorients screen-reader and keyboard users.jsx-a11y/no-distracting-elements: Disallow deprecated marquee and blink elements, which distract users and can trigger vestibular issues.