Help:Lint エラー/duplicate-ids
| MediaWiki バージョン: | 1.43 |
要素の id 属性の値は、文書内で一意であることが想定されています。 このカテゴリの Lint エラーは、同じ id 属性の値がページ内の複数の要素で使用されている箇所を指摘します。 このエラーは現在「高優先度」として分類されていますが、多くの場合、例えば英語版ウィキペディアの出典テンプレートなどでは、ID が使用されておらず、問題を引き起こすことはありません。
悪い例
<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).
Examples of fix
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
This lint error was first requested in T200517 (2018年7月).
However, the impetus for implementing it was the Parsoid/パーサーの統一 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 2024年9月, 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 2025年11月, there were over 23,000,000 pages suffering from duplicate IDs on English wikipedia.