No missing references

Rule ID:
no-missing-references
Category:
Document
Standards:
  • HTML5

Require all elements referenced by attributes such as for to exist in the current document.

Checked attributes:

A current limitation is that only the <title> and <desc> elements from an SVG can be referenced.

Rule details

Examples of incorrect code for this rule:

<label for="missing-input"></label>
<div aria-labelledby="missing-text"></div>
<div aria-describedby="missing-text another-missing"></div>
error: Element references missing id "missing-input" (no-missing-references) at inline:1:13:
> 1 | <label for="missing-input"></label>
    |             ^^^^^^^^^^^^^
  2 | <div aria-labelledby="missing-text"></div>
  3 | <div aria-describedby="missing-text another-missing"></div>


error: Element references missing id "missing-text" (no-missing-references) at inline:2:23:
  1 | <label for="missing-input"></label>
> 2 | <div aria-labelledby="missing-text"></div>
    |                       ^^^^^^^^^^^^
  3 | <div aria-describedby="missing-text another-missing"></div>


error: Element references missing id "missing-text" (no-missing-references) at inline:3:24:
  1 | <label for="missing-input"></label>
  2 | <div aria-labelledby="missing-text"></div>
> 3 | <div aria-describedby="missing-text another-missing"></div>
    |                        ^^^^^^^^^^^^


error: Element references missing id "another-missing" (no-missing-references) at inline:3:37:
  1 | <label for="missing-input"></label>
  2 | <div aria-labelledby="missing-text"></div>
> 3 | <div aria-describedby="missing-text another-missing"></div>
    |                                     ^^^^^^^^^^^^^^^


4 errors found.

Examples of correct code for this rule:

<label for="my-input"></label>
<div id="verbose-text"></div>
<div id="another-text"></div>
<div aria-labelledby="verbose-text"></div>
<div aria-describedby="verbose-text another-text"></div>
<input id="my-input">

Version history