Help:Lint errors/duplicate-ids
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.
Example
<div id="test">123</div>
<p>hmm</p>
<div id="test">456</div>
The ID test
is duplicated.
Do not use duplicate IDs
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).
Example
An edit of a template to add a class on an element and the corresponding edit of Javascript to target the class.
History
This Lint error was first requested in T200517. However, the impetus for implementing it now is the 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.
Category:Linter