Skip to main content

no-refer-to-non-existent-id

Check whether the ID or the list of ID specified to for, form, aria-*, and more, or a fragment in a hyperlink are referencing it that existed in the same document.

❌ Examples of incorrect code for this rule

<label for="foo">Text Field</label><input id="bar" type="text" />

<a href="#baz">Fragment link</label>
<section id="qux">...</section>

✅ Examples of correct code for this rule

<label for="foo">Text Field</label><input id="foo" type="text" />

<a href="#baz">Fragment link</label>
<section id="baz">...</section>

Interface

{
"no-refer-to-non-existent-id": boolean
}

Options

{
"no-refer-to-non-existent-id": {
"options": {
"ariaVersion"?: "1.1" | "1.2"
"fragmentRefersNameAttr"?: boolean
}
}
}
PropertyTypeDefault ValueDescription
ariaVersion"1.1" | "1.2""1.2"Choose the version of WAI-ARIA to evaluate.
fragmentRefersNameAttrbooleanfalseThe fragment refers to IDs but also the value of name attributes.

Default Severity

error