- Published on
- 2 min read
Forms that explain themselves
- Authors
- Name
- Ritenta
A field can look clear in a screenshot and still be difficult to use. A placeholder disappears when someone starts typing; an error at the top of a page may not identify the field that needs attention. Build each field as a small conversation: what is this input, what format should I use, and what happened after I submitted it?
Give the control a real name
Use a visible <label> linked to the control's id. Clicking the label then focuses the input, and assistive technology can associate the name with the field. The label should describe the data, not merely say “Required.” MDN documents the label association.
<label for="work-email">Work email</label>
<p id="email-help">Use an address you can open during registration.</p>
<input id="work-email" name="email" type="email" autocomplete="email"
aria-describedby="email-help email-error" aria-invalid="true" required>
<p id="email-error">Enter an email address such as name@example.com.</p>
The snippet shows the invalid state: the instruction gives context, and the error gives a repair action. Before an error occurs, omit the error element from aria-describedby or keep it empty and hidden. On an invalid submission, set aria-invalid="true", show the relevant error, and move attention to an error summary or the first invalid field using a deliberate focus strategy. Avoid showing a red border as the only signal.
Keep grouping and timing predictable
Related radio buttons need a group name. A <fieldset> with a <legend> gives that name without inventing extra ARIA. State any format or character limit before the user submits, then report errors beside the controls. W3C's forms tutorial covers labels, grouping, instructions and validation as connected parts of the same experience.
Try this check with a keyboard and a screen reader: tab to every field, ask what its name and instructions are, submit an empty form, then find and fix each error without guessing. The form is ready when the answer is clear at each step.