Sub topic 3
Designing forms with labels, hints and errors
This chapter assumes you know basic wireframing, common UI components such as forms and buttons, and how HTML elements, attributes and ARIA roles fit together. It covers forms, link text, reflow, annotations, semantic markup and early checks.
Forms: labels, hints and errors
Give every field a visible, persistent label. Placeholder text disappears once someone types, so it cannot replace a label. Add a hint for format rules, and write an error message that says how to fix the problem. Link the hint and error to the input with aria-describedby so screen readers announce them.
<label for="email">Email address</label>
<p id="email-hint">We will send your receipt here.</p>
<input id="email" name="email" type="email" autocomplete="email"
required aria-invalid="true"
aria-describedby="email-hint email-error">
<p id="email-error">Enter an email address in the format [email protected].</p>Planning text alternatives and meaningful link text
Link text should make sense out of context. A screen reader user often navigates by a list of links, so five links labeled "Read more" give no clue where each one goes. Write "Read more about refund policy" instead. For icon-only buttons, note the accessible name in the wireframe, such as "Delete item".
Planning for reflow, zoom and small screens
Reflow means content rearranges into a single column when the window narrows or the user zooms. WCAG's Reflow criterion expects content to work at 320 CSS pixels wide without horizontal scrolling, which equals 400% zoom on a 1280-pixel screen. Sketch the narrow layout beside the desktop layout, and confirm a two-column form stacks into one column.
Annotating wireframes for handoff
Annotations pass your intent to developers. Note the behavior of each interactive element.
| Element | Annotation |
|---|---|
| Email field | Visible label, hint linked with `aria-describedby`, error text shown on submit |
| Search icon button | Accessible name "Search" |
| Site navigation | Navigation landmark labeled "Main" |
Mapping design intent to native HTML and ARIA
Use native elements first. A <button> receives keyboard focus and responds to Enter and Space, and it has the button role without extra code. ARIA attributes add meaning but do not add behavior, so <div role="button"> still needs custom key handling.
<!-- Preferred: native element -->
<button type="button">Save changes</button>Checking designs early
Check the low-fidelity wireframe before visual design starts.
- Does every field have a visible label?
- Does each link make sense on its own?
- Does the layout stack at 320 pixels?
- Does every interactive element have an annotation?
Exercise
Exercise
A sign-up form shows the text "Email" inside the input as a placeholder and has no label. What is the problem, and how should you fix it?
Show answer
The placeholder disappears as soon as the user types, and screen readers may not announce it reliably. Add a persistent visible label with <label for="email">Email</label> and keep the placeholder optional.