Make forms understandable to everyone
Connect labels, help text, errors, and focus.
Use native form behavior
Give each control a visible label and a stable id. Use the correct input type and let the browser handle basic keyboard interaction. Group related controls with fieldset and legend. Placeholder text disappears as someone types and should not be the only label.
Announce validation clearly
When validation fails, place a specific message beside the field and associate it with aria-describedby. Set aria-invalid for the affected control. Provide a summary if several fields fail, and move focus to the summary or first invalid field so keyboard users can find the problem.
<label for="email">Email</label>
<input id="email" aria-invalid="true" aria-describedby="email-error">
<p id="email-error">Enter a valid email address.</p>
Test the experience
Submit with an empty required field, a malformed value, and valid input. Check the visible text, the association between input and error, and where focus lands. A screen reader pass can reveal confusing repeated announcements that a DOM assertion will not catch.
Check your understanding
Why should a form error be linked with aria-describedby?
Show explanation
It gives assistive technology a programmatic connection between the field and its explanatory message.
You can read for free. Create an account to save your progress.
← Previous lesson: Understand events, delegation and equality Next lesson: Model state with discriminated unions →Put this lesson into practice
A practice activity at this level in the same module.
Try: Make a custom list keyboard accessibleFurther reading
Primary references for this module. Check the current version when behavior or framework guidance may have changed.