Free, independent guides since 2010

Accessibility

Accessible forms: labels, errors and instructions

How to build accessible web forms: visible labels, grouping with fieldset and legend, instructions, required fields, error messages, autocomplete, time limits and accessible custom controls.

<guide section="Accessibility" type="article" read="1 min"/>

Forms are where accessibility problems cost the most: an inaccessible contact or checkout form means a lost customer. Combine this page with web forms UX and HTML form validation.

Labels

HTML
<label for="email">Email address</label>
<input id="email" name="email" type="email" autocomplete="email" required aria-describedby="email-help">
<p id="email-help">We only use this to reply to your question.</p>
  • Visible text, connected with for and id.
  • Instructions linked with aria-describedby.
  • Clicking the label focuses the field – a bigger target for everyone.

Groups

HTML
<fieldset>
  <legend>Preferred contact method</legend>
  <label><input type="radio" name="contact" value="email"> Email</label>
  <label><input type="radio" name="contact" value="phone"> Phone</label>
</fieldset>

Required fields

Use the required attribute and say it in text: “Name (required)”, or explain at the top that all fields are required except those marked optional.

Errors

HTML
<label for="zip">Postcode</label>
<input id="zip" name="zip" aria-invalid="true" aria-describedby="zip-err">
<p id="zip-err" class="error">Enter a postcode of four digits, for example 2000.</p>
  • Say what is wrong and how to fix it.
  • Do not clear correct fields after an error.
  • Do not rely on colour alone (see contrast).

More good practice

  • Autocomplete attributes for personal data (name, email, address, phone).
  • No time limits, or a way to extend them.
  • Do not ask for the same information twice in a process (WCAG 2.2).
  • Avoid CAPTCHAs that require seeing or hearing (see form spam).
  • Custom selects and date pickers must work with keyboard and screen reader – or use native ones.

Frequently asked questions

Can I use placeholder text instead of a label?

No. Placeholders disappear when typing, often have low contrast and are not reliably read as labels. Use a real label; a placeholder can show an example.

How should I announce errors?

Show a summary at the top with links to the fields, and messages next to each field linked with aria-describedby. Move focus to the summary or the first error after submitting.