Help:Lint errors/duplicate-ids
| MediaWiki version: | 1.43 |
An element's id attribute value is intended to be unique in the document. Lint errors in the category duplicate-ids 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 automatically generated and cannot be manually modified.
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 (July 2018).
However, the impetus for implementing it was 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.
T200517 was closed as resolved in September 2024, adding a special page Special:LintErrors/duplicate-ids.
Fixing these errors is requested of editors since it can improve rendering compatibility when Parsoid is enabled on a wiki.
As of November 2025, there were over 23,000,000 duplicate id errors tracked on the English Wikipedia.