Accessibility

a11y/aria-ref-exists

Ids named in aria-labelledby, aria-describedby and aria-errormessage exist in the page and are unique.

seriousstaticWCAG 1.3.1, 4.1.2 · Afe-a11y-aria

Why

A reference to a missing id is dropped without a warning, so the hint, the error or the label is never read. When two elements share the id, the first one wins and the user may hear the wrong text.

Fix

Correct the id or the reference, and make ids unique per page. In components, generate ids (useId() in React and Vue 3.5, $props.id() in Svelte 5) and pass them down instead of hard-coding them.

Examples

<!-- bad -->
<input id="email" aria-describedby="email-hint"><p id="emailhint">…</p>
<!-- good -->
<input id="email" aria-describedby="email-hint"><p id="email-hint">…</p>

Sources

Facts

Id
a11y/aria-ref-exists
Severity
serious
Check
static checked in the source by audit
Applies to
html
WCAG 2.2
1.3.1, 4.1.2, level A
Same problem in
axe-core aria-valid-attr-value, axe-core duplicate-id-aria
Taught by the skill
fe-a11y-aria ARIA, names and live regions
Since version
0.1.0

Rule file on GitHub

Read it in the terminal

npx github:dawidolko/frontend-skills explain a11y/aria-ref-exists