Skip to content

no-duplicate-id

Reports an id that an earlier element of the document already has.

Ids must be unique. Scripts, links, labels and styles find the first element only, so the second one is silently unreachable.

To fix, give the element another id.

Reported
...
<main hidden></main>
...
<p id="a"></p>
<p id="a"></p>
...
<p id=""></p>
<ul><li>a</li></ul>
...
angular:
lint:
rules:
no-duplicate-id: warn # off, warn (default), error
html:
lint:
rules:
no-duplicate-id: warn # off, warn (default), error
svelte:
lint:
rules:
no-duplicate-id: warn # off, warn (default), error
vue:
lint:
rules:
no-duplicate-id: warn # off, warn (default), error

Enabled by the presets: html/html-validate-standard, html/htmlhint, html/html-eslint-recommended.

Suppress one line with sudsy-disable-next-line no-duplicate-id in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
html-eslint no-duplicate-id full
html-validate no-dup-id partial ids are not scoped per <template>; no include and exclude options
htmlhint id-unique full