Form Labels
Checks that form inputs have associated labels
Checks that form inputs have associated labels
| Rule ID | a11y/form-labels |
| Category | Accessibility |
| Scope | Per-page |
| Severity | error |
| Weight | 6/10 |
Solution
Every form input needs an accessible label for screen readers. Options: 1) Use <label for='inputId'>Label</label> with matching id. 2) Wrap the input inside <label>Label <input>``</label>. 3) Use aria-label or aria-labelledby for inputs where visible labels aren’t feasible. Placeholders are not sufficient substitutes for labels. Hidden inputs, submit buttons, and image buttons don’t need labels.
Enable / Disable
Disable this rule
squirrel.toml
toml[rules]
disable = ["a11y/form-labels"]Disable all Accessibility rules
squirrel.toml
toml[rules]
disable = ["a11y/*"]Enable only this rule
squirrel.toml
toml[rules]
enable = ["a11y/form-labels"]
disable = ["*"]