Help:Lint errors/duplicate-ids
- English
- 日本語
An element's id
attribute value is intended to be unique in the document. Lint errors in this category highlight instances where the same id
attribute value is being used on multiple elements in the page. This error is currently listed as "high-priority", but in many cases, such as citation templates on the English Wikipedia, the IDs are not used and cannot create any problems.
Bad example
[edit ]<div id="test">123</div> <p>hmm</p> <div id="test">456</div>
The ID test
is duplicated.
Do not use duplicate IDs
[edit ]HTML documents should not be using duplicate IDs on elements. If your CSS or JavaScript code targets elements with an ID, where you expect multiple elements on a page to get the same ID, use a CSS class instead to target them (or use other CSS selectors where applicable).
Examples of fix
[edit ]An edit of a template to add a class on an element and the corresponding edit of JavaScript to target the class. A simpler example of editing the CSS template and fix of the page using it.
History
[edit ]This lint error was first requested in T200517. However, the impetus for implementing it now is the Parsoid/Parser Unification project. Parsoid , the new wikitext parser, enforces deduplication of element IDs where necessary - this is a change from how the legacy wikitext parser does things. Fixing these errors is requested of editors since it can improve rendering compatibility when Parsoid is enabled on a wiki.