Documentation/IDs must be unique

IDs must be unique

ZMD016

ZemDomu reports the same static id value more than once in the analyzed document or supported component structure. Give each element a unique id so labels, ARIA references, fragment links, and scripts resolve unambiguously.

What this rule catches

  • Duplicate literal id values in supported source files.
  • Duplicate ids introduced when supported components are combined in the analyzed project structure.

What static analysis cannot prove

  • Static analysis cannot prove uniqueness for ids generated from runtime data or across states that are not represented in source.
  • Passing the rule does not prove that every id reference points to the intended element.

Standards classification and detection confidence

Classification
normativeThe rule checks HTML's requirement that id values be unique within a document.
Detection confidence
context dependentDuplicates are reliable within the resolved page model. Runtime repetition, generated ids, portals, and unresolved branches can change the final document.

Applicable WCAG 2.2 criteria

No direct WCAG 2.2 success criterion.

WCAG 2.2 removed the former Parsing success criterion. Unique ids remain an HTML conformance and relationship-integrity requirement, not a standalone WCAG 2.2 criterion.

Normative means the rule checks a machine-testable part of a cited standards requirement. Advisory means it enforces a documented authoring convention or supporting technique. Neither classification makes a ZemDomu result proof of WCAG conformance.

Examples

✅ Good

<div id="item-1"></div>
<div id="item-2"></div>

❌ Bad

<div id="item"></div>
<div id="item"></div>

React and Vue notes

React/TSX
Repeated component instances can duplicate hard-coded JSX or TSX ids; prefer useId or another instance-safe strategy and verify the rendered document.
Vue
Repeated component instances can duplicate hard-coded template ids; generate instance-safe ids and verify the rendered document.

Quick summary

When: The same id attribute appears more than once

Warning: Duplicate id "X"

Solution: Ensure each id value is unique

Why it matters

Accessibility: Assistive technologies may skip or misattribute content when IDs collide.

SEO: Fragment links (`#id`) may unpredictably navigate to the wrong section or not at all.

Rule details

In brief

  • Goal: Prevent duplicate identifiers in the HTML document.
  • What to do: Audit the codebase and assign unique id values to each element.
  • Why: Duplicate IDs break internal links, scripting, and confuse screen readers.

Intent

Maintain a one-to-one mapping between IDs and elements for reliable navigation and scripting.

Benefits

  • Consistent behavior of document.querySelector and getElementById.
  • Accurate fragment link navigation (e.g., example.com/page#section).

Techniques

  • H93: Ensuring that id attributes are unique on a Web page.

HTML Semantics

The id global attribute must be unique per the HTML specification to identify elements unambiguously.

Tips & edge cases

  • Run an automated audit (e.g., axe, HTML validator) to catch duplicate IDs before deployment.