no-duplicate-h1
ドキュメント内にh1要素が複数あれば警告します。
このルールは、WCAG 2.0の達成基準 1.3.1のための達成方法 H42と、見出しレベルのスキップに関するプラクティス、およびWeb Accessibility Tutorials - Headings (英語ページ)に基づいて設けられています。
旧required-h1ルールから、require-h1とともに分割されました。
❌ 間違ったコード例
<html>
<body>
<h1>heading</h1>
<main>
<h1>another heading</h1>
</main>
</body>
</html>
✅ 正しいコード例
<html>
<body>
<h1>heading</h1>
<main>
<h2>subheading</h2>
</main>
</body>
</html>
Interface
{
"no-duplicate-h1": boolean
}
Options
{
"no-duplicate-h1": {
"options": {
"in-document-fragment"?: boolean
}
}
}
| Property | Type | Default Value | Description |
|---|---|---|---|
in-document-fragment | boolean | "false" | ドキュメント全体ではなく、コードの断片内でこのルールを適用させたい場合、trueにしてください。 |
Default Severity
warning