Ensure all element IDs are unique within the page
Content available in English only.
Accessibility isn’t just about avoiding violations — it’s about ensuring that everyone can use your product with confidence. This guide explains each rule’s intent, highlights common issues, and shows how to fix them according to WCAG and the European Accessibility Act (EAA).
These guidelines do not replace the official WCAG standards. They’re concise, developer-focused notes to help you identify and fix issues effectively.
Every ID must be unique — never reuse the same ID on multiple elements.
Why this matters and how to fix it
Why this matters
IDs are used to create explicit relationships in accessibility (e.g., labels, error messages, descriptions). If two elements share the same ID, assistive technologies and browsers may associate labels or messages with the wrong element, leading to incorrect or misleading announcements.
How to fix this issue
Ensure every `id` is unique within the document. In component-based systems, do not hardcode IDs—generate them dynamically or use naming patterns. For repeated components, append a unique token, index, or UUID.
Developer guidance
This failure most often appears in form components, list items, repeated modals, and tables. In design systems, ensure components receive `id` as a prop instead of defining a fixed internal ID. Enable linting to detect duplicate IDs during development.
Code examples
Incorrect Implementation
<label for="email">Email</label>
<input id="email" />
<input id="email" />Correct Implementation
<label for="email-1">Email</label>
<input id="email-1" />
<label for="email-2">Email</label>
<input id="email-2" />Real-World Examples
Before
<form>
<UserEmailField />
<UserEmailField />
</form>
<!-- Component contains internal id="email" hardcoded → duplicated in DOM -->After
<form>
<UserEmailField id="email-primary" />
<UserEmailField id="email-secondary" />
</form>
<!-- Component accepts id as a prop → unique per instance -->Manual testing
- 1. Open browser dev tools and inspect the DOM.
- 2. Search for: id="..." → verify each appears only once.
- 3. If testing a form: ensure every <label for="id"> points to exactly one input.
- 4. Turn on a screen reader and navigate the form.
- • Expected: Each label is announced with the correct input.
- • Failure case: The screen reader announces the wrong label or skips fields.
- 5. If using repeatable components: trigger UI that adds dynamic items (e.g., “Add new address”). Confirm new IDs are generated instead of duplicated.
Trusted by organizations across Europe working toward WCAG and EAA conformance