Accessible forms
Forms are where users accomplish tasks (sign up, buy, submit), and
inaccessible forms block those tasks entirely for some users. The
requirements are concrete: every field labeled and associated, every
error identified in text, instructions available, and the browser's
autofill enabled.
Method
- Associate a real label with every field. A
<label for="email"> tied to the input's id (or wrapping
it): so clicking the label focuses the field and the
screen reader announces the label when the field gets
focus (see aria-usage: prefer real labels to aria-label).
Placeholder text is not a label (it disappears on input
and often fails contrast: see color-contrast); a field
labeled only by placeholder is unlabeled the moment the
user types.
- Identify errors in text, associated with the field.
When validation fails: describe the error in text ("Email
must include an @"), associate it with the field
(
aria-describedby pointing to the error message), and
move focus to (or announce: see screen-reader-testing's
live regions) the first error. Color alone (a red border)
does not tell a screen-reader or color-blind user what
is wrong (see color-contrast's don't-rely-on-color):
the error must be text they can perceive.
- Provide instructions and requirements up front.
Format requirements, which fields are required, and
constraints stated before the user submits and fails:
"Password must be at least 12 characters" shown with the
field, not only in the error after. Required fields
marked in text and with
aria-required (not by color or
an asterisk alone: see the multi-channel rule). Users
should know the rules before hitting them.
- Enable autocomplete and the right input types.
autocomplete attributes (autocomplete="email",
"name", "one-time-code") let browsers and password
managers autofill: a huge help for users with motor or
cognitive disabilities, and everyone else (see the
autofill discipline in mobile-input-ux). Correct input
type (email, tel, number) triggers the right keyboard
and validation. These reduce the typing burden that
forms impose.
- Group related fields and controls. Radio buttons and
checkboxes for one question grouped in a
<fieldset>
with a <legend> (so the screen reader announces the
group's question with each option); related sections
with headings. Ungrouped radio options announce
individually with no context ("yes, radio button" with
no question) leaving users lost.
- Keep the submit path clear and forgiving. The submit
button reachable and labeled with its action ("Create
account", not "Submit"); errors on submit do not clear
entered data (see form-handling); success confirmed in a
way screen readers announce. A form that clears itself on
error or gives no submission feedback fails users
exactly at the moment of completing their task.
Boundaries
- Accessible forms combine several techniques (labels,
errors, keyboard, focus: see keyboard-navigation,
focus-management, screen-reader-testing); a form is
accessible only when all hold, and the whole task can be
completed with keyboard and screen reader.
- Complex custom form controls (date pickers, comboboxes,
multi-selects) need the full ARIA widget patterns (see
aria-usage) and are easy to get wrong; prefer native
inputs or well-tested accessible libraries over custom
ones where possible.
- Client-side validation UX (timing, inline vs on-submit:
see form-handling) and accessibility overlap; the
accessibility requirements (text errors, association,
focus) apply regardless of the validation timing chosen.
1---2name: accessible-forms3description: Build forms with associated labels, identified errors, clear instructions, and autocomplete attributes. Use when creating or auditing forms for accessibility.4---56# Accessible forms78Forms are where users accomplish tasks (sign up, buy, submit), and9inaccessible forms block those tasks entirely for some users. The10requirements are concrete: every field labeled and associated, every11error identified in text, instructions available, and the browser's12autofill enabled.1314## Method15161. **Associate a real label with every field.** A17 `<label for="email">` tied to the input's id (or wrapping18 it): so clicking the label focuses the field and the19 screen reader announces the label when the field gets20 focus (see aria-usage: prefer real labels to aria-label).21 Placeholder text is not a label (it disappears on input22 and often fails contrast: see color-contrast); a field23 labeled only by placeholder is unlabeled the moment the24 user types.252. **Identify errors in text, associated with the field.**26 When validation fails: describe the error in text ("Email27 must include an @"), associate it with the field28 (`aria-describedby` pointing to the error message), and29 move focus to (or announce: see screen-reader-testing's30 live regions) the first error. Color alone (a red border)31 does not tell a screen-reader or color-blind user what32 is wrong (see color-contrast's don't-rely-on-color):33 the error must be text they can perceive.343. **Provide instructions and requirements up front.**35 Format requirements, which fields are required, and36 constraints stated before the user submits and fails:37 "Password must be at least 12 characters" shown with the38 field, not only in the error after. Required fields39 marked in text and with `aria-required` (not by color or40 an asterisk alone: see the multi-channel rule). Users41 should know the rules before hitting them.424. **Enable autocomplete and the right input types.**43 `autocomplete` attributes (`autocomplete="email"`,44 `"name"`, `"one-time-code"`) let browsers and password45 managers autofill: a huge help for users with motor or46 cognitive disabilities, and everyone else (see the47 autofill discipline in mobile-input-ux). Correct input48 `type` (email, tel, number) triggers the right keyboard49 and validation. These reduce the typing burden that50 forms impose.515. **Group related fields and controls.** Radio buttons and52 checkboxes for one question grouped in a `<fieldset>`53 with a `<legend>` (so the screen reader announces the54 group's question with each option); related sections55 with headings. Ungrouped radio options announce56 individually with no context ("yes, radio button" with57 no question) leaving users lost.586. **Keep the submit path clear and forgiving.** The submit59 button reachable and labeled with its action ("Create60 account", not "Submit"); errors on submit do not clear61 entered data (see form-handling); success confirmed in a62 way screen readers announce. A form that clears itself on63 error or gives no submission feedback fails users64 exactly at the moment of completing their task.6566## Boundaries6768- Accessible forms combine several techniques (labels,69 errors, keyboard, focus: see keyboard-navigation,70 focus-management, screen-reader-testing); a form is71 accessible only when all hold, and the whole task can be72 completed with keyboard and screen reader.73- Complex custom form controls (date pickers, comboboxes,74 multi-selects) need the full ARIA widget patterns (see75 aria-usage) and are easy to get wrong; prefer native76 inputs or well-tested accessible libraries over custom77 ones where possible.78- Client-side validation UX (timing, inline vs on-submit:79 see form-handling) and accessibility overlap; the80 accessibility requirements (text errors, association,81 focus) apply regardless of the validation timing chosen.