Unique Id
ID |
html.id_unique |
Severity |
high |
Remediation Complexity |
trivial |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Reliability |
Language |
Html |
Tags |
reliability |
Rationale
The id attribute must be unique across a document: it is the target of fragment links,
label[for] associations, aria-* references and document.getElementById lookups. When two
elements share an id the browser keeps only the first match, so styles, scripts and accessibility
relations silently bind to the wrong element.
<div id="dup">first</div> <!-- FLAW — id reused below -->
<div id="dup">second</div> <!-- FLAW — duplicate id -->
<div id="unique">ok</div> <!-- OK — used only once -->
Remediation
Give each element a distinct id. If several elements need to share styling or behaviour, use a
class instead, which is allowed to repeat.