Disallows elements with duplicated ID
- Rule ID:
- no-dup-id
- Category:
- Document
- Standards:
- HTML5
- Fixable:
- No
The ID of an element must be unique within the document.
When <template> is used the id within the template must be unique but can otherwise contain duplicates as it isn't attached to the document yet.
Rule details
Examples of incorrect code for this rule:
<div id="foo"></div>
<div id="foo"></div>
Examples of correct code for this rule:
<div id="foo"></div>
<div id="bar"></div>
Options
This rule takes an optional object:
{
"include": null,
"exclude": null
}
include
- type:
string[] | null - default:
null
If set only IDs matching one or more patterns in this array are checked for duplicates.
Supports wildcard with * (e.g. foo-*) and regexp with /../ (e.g. /^foo-\d+$/).
exclude
- type:
string[] | null - default:
null
If set IDs matching one or more patterns in this array are ignored.
Supports wildcard with * (e.g. foo-*) and regexp with /../ (e.g. /^foo-\d+$/).
Version history
- 11.9.0 -
includeandexcludeoptions added.