Accessible Form Labeling for Inputs
Rule ID: label
Ruleset: axe-core 4.10
User Impact: Critical
Guidelines: WCAG 2.1 (A), WCAG 2.0 (A), WCAG 2.2 (A), Section 508, Trusted Tester, EN 301 549
How to Fix the Problem
Ensure every form input element — such as <input>
, <textarea>
, <select>
, checkboxes, and radio buttons — has a clear, programmatically associated label.
Recommended Methods:
1. Explicit <label>
with for
and id
attributes
This is the most reliable and accessible technique:
2. Implicit Label (Label Wrapping)
Enclose the input within a <label>
tag:
3. Use aria-label
for Invisible Labels
When a visible label is not feasible:
4. Use aria-labelledby
when referencing multiple label sources
This is ideal when visual labels are elsewhere or when multiple labels apply:
Note: Always ensure that all
id
values used are unique.
5. Avoid Using Only Placeholder Attributes
Avoid relying solely on placeholder
as it disappears when the user starts typing:
Elements That Must Have Labels:
-
<input type="text">
-
<input type="password">
-
<textarea>
-
<input type="radio">
-
<input type="checkbox">
Exceptions:
-
<button>
elements — already self-labeled -
<input type="hidden">
— hidden from user interaction and doesn’t need a label
Common Mistake to Avoid:
While this visually appears correct to sighted users, screen readers will not associate the text “First name:” with the input unless it is programmatically linked using <label>
.
Also, avoid assigning multiple labels to a single input, and ensure help text is distinct from the label itself.
Why it Matters
Labels are critical for accessibility. Sighted users can often infer the purpose of a form field through visual proximity, but screen reader users depend entirely on programmatic associations.
Without a label:
-
Screen readers may announce the input without context, making it unclear what data is expected.
-
Fields may not receive proper focus.
-
Users with motor impairments lose the larger clickable area provided by labels.
A well-implemented label ensures that every user — regardless of their abilities — can interact with forms clearly, efficiently, and independently.
Rule Description
Each form input element must be explicitly or implicitly labeled using standard HTML or ARIA techniques. This ensures users of assistive technologies can understand and interact with form elements.
The Algorithm (in simple terms)
The rule checks that:
-
Each
<input>
,<textarea>
, or<select>
element (excluding buttons and hidden inputs) has a label. -
The label is associated via:
-
A
<label>
with afor
attribute referencing the input’sid
, or -
A wrapping
<label>
, or -
An
aria-label
oraria-labelledby
attribute.
-
-
The label text is meaningful and unique on the page.