Unique IDs for ARIA references

Last updated:

How to fix duplicate-id-aria?

Each ID on a page must appear only once. When using ARIA attributes that reference an ID, verify that the target ID is unique:

CORRECT:

unique IDs

<label id="email-label">Email address</label>
<input type="email" aria-labelledby="email-label"/>

<label id="phone-label">Phone number</label>
<input type="tel" aria-labelledby="phone-label"/>
CORRECT:

aria-describedby with unique ID

<input type="password" aria-describedby="password-hint"/>
<p id="password-hint">Use at least 8 characters.</p>

The following is invalid because two elements share the same ID:

BAD:

duplicate ID

<label id="field-label">Email address</label>
<input type="email" aria-labelledby="field-label"/>

<label id="field-label">Phone number</label>
<input type="tel" aria-labelledby="field-label"/>

In the example above, both inputs reference field-label, so the second input may be announced incorrectly or not at all.

Why is this important?

ARIA attributes work by referencing IDs on the page. When IDs are duplicated, browser behavior is unpredictable.

More info:

WCAG 4.1.1 Parsing.

Rule info

Standard

WCAG A SC 4.1.2

Regulations

EN 301 549 RGAA EAA AODA

User impact

Fix complexity

Affects

Was this article helpful?

Checkout the ExcellentWebCheck services

ExcellentWebCheck's goal is to improve the online user experience. The tools of ExcellentWebCheck help to detect and improve usability problems on your website.