IDs of focusable elements should be unique
Deprecated: buttons, links and other focusable elements should each have a unique id. WCAG 2.2 made criterion 4.1.1 obsolete; duplicate-id-aria now covers the ids that affect accessibility.
Deprecated
| Rule ID | duplicate-id-active |
|---|---|
| Impact | Serious |
| Success criterion | 4.1.1 Parsing · A |
| Needs a change in the website’s code |
Example
<button id="add-to-cart">Add to cart</button>
<!-- sticky bar on mobile -->
<button id="add-to-cart">Add to cart</button>A script or link targeting #add-to-cart reaches only the first button; the sticky one may do nothing.
<button id="add-to-cart">Add to cart</button>
<!-- sticky bar on mobile -->
<button id="add-to-cart-sticky">Add to cart</button>Each button can be targeted on its own, so both work for keyboard and screen reader users.
Why it matters
An id should identify one element. When two focusable elements share it, scripts, skip links and href="#…" targets reach only the first one. A keyboard user who follows an in-page link can land in the wrong place, and a button wired up by id may silently do nothing.
This rule tested WCAG 1.0-era parsing (success criterion 4.1.1), which WCAG 2.2 removed because modern browsers handle duplicate ids consistently. The check is deprecated and off by default. Duplicate ids still cause real bugs, so fixing them remains good practice, and the ones that break labels or ARIA are reported by duplicate-id-aria.
How to fix it
Rename the duplicates so each focusable element has its own id, then update every script, style and link that refers to it.
Repeated controls. Add a suffix that says where the copy lives, or the item number:
<a id="faq-shipping" href="#shipping">Shipping</a>
<a id="faq-returns" href="#returns">Returns</a>
Styling and scripts. If the id is there only for CSS or JavaScript, use a class or a data attribute instead, which may repeat freely:
<button class="add-to-cart" data-sku="SH-1042">Add to cart</button>
<script>
document.querySelectorAll(".add-to-cart").forEach((b) => b.addEventListener("click", addToCart));
</script>
Components. Generate ids per instance (useId() in React, a counter in templates) instead of hard-coding them.
You can find all duplicates by running [...document.querySelectorAll("[id]")].map(e => e.id).filter((id, i, a) => a.indexOf(id) !== i) in the browser console.
Checklist
- Give each focusable element a unique id.
- Use classes or data attributes for styling and scripts.
- Generate ids per component instance.
- Update links and scripts after renaming.
How the check works
The check looks at focusable and interactive elements (links, buttons, form fields, elements with tabindex) that have an id, and fails when another element on the page uses the same id. It is deprecated and disabled by default, because WCAG 2.2 removed the criterion it tested. Duplicate ids used by labels or ARIA are reported by a separate check.
Resources
- Understanding 4.1.1 Parsing W3C
- W3C ACT rule 3ea0c8 W3C ACT
- Developing for web accessibility: tips W3C WAI
Updated October 27, 2026