Skip to main content
Raasta
CriticalWCAG 4.1.2 · Level Aduplicate-id-aria

ID used by a label or ARIA is not unique

When two elements share an id that a <label>, aria-labelledby or aria-describedby points to, the wrong text can be read for a field, or none at all. Make every id on the page unique, especially ids created inside loops and reused components.

Who it hurts

Screen reader users and voice control users, who get the wrong label for a field or control.

A newsletter form in both the header and the footer, or a quantity field in every cart row, often repeats the same id.

How to fix it

Pick your stack. Review every change before you ship it.

Before

<label for="email">Email</label><input id="email"> <!-- header -->
<label for="email">Email</label><input id="email"> <!-- footer -->

After

<label for="header-email">Email</label><input id="header-email">
<label for="footer-email">Email</label><input id="footer-email">

Check it by hand too

Tab through repeated forms and fields with a screen reader on. Each should read its own label, and clicking a label should focus its own field.

Automated checks find a large share of accessibility problems, but not all of them. Passing this check does not on its own make a page compliant.

WCAG reference