Ensure every form element has a label
Ensure that all form elements, such as <input>
, <textarea>
, and <select>
, have associated labels to convey their purpose to users, especially those relying on assistive technologies.
About This Rule
This rule ensures that form elements have associated labels, enhancing accessibility for users who rely on screen readers. Adhering to this guideline aligns with the following standards:
- WCAG 2.1 (A): 4.1.2 Name, Role, Value
- WCAG 2.0 (A): 4.1.2 Name, Role, Value
- WCAG 2.2 (A): 4.1.2 Name, Role, Value
- Section 508: 1194.22 (n)
- Trusted Tester: 5.C
- EN 301 549: 9.4.1.2 Name, Role, Value
Why It Matters
Labels provide essential context for form controls, enabling users to understand the expected input. Without proper labels, users who are blind, have low vision, or rely on screen readers may struggle to interact with forms effectively, leading to confusion and errors.
How to Fix
To ensure form elements are accessible:
-
Explicit Labeling: Use the
<label>
element with afor
attribute that matches theid
of the form control: -
Implicit Labeling: Wrap the form control with the
<label>
element: -
Using
aria-label
: For controls labeled visually by other means (e.g., an icon), provide an accessible name: -
Using
aria-labelledby
: Reference existing elements that serve as labels: -
Avoid Sole Reliance on
placeholder
: While theplaceholder
attribute can provide hints, it should not replace labels, as placeholder text disappears upon user input:
Examples
Incorrect
An input field without an associated label:
Correct
An input field with an explicit label:
More Information
Other Rules
Interested in other web accessibility rules? Please see these other rules: