How to build an accessible contact form (WCAG checklist with code)

Make your contact form usable by everyone, including keyboard and screen reader users. Labels, errors, focus, status messages, honeypots and colour contrast, with copy-paste HTML.

· 3 min read

An accessible contact form with visible labels and focus states

A contact form is often the single most important interactive element on a small business website. If someone using a screen reader, a keyboard or voice control cannot complete it, that lead is gone, and in many countries you may also be failing legal accessibility requirements.

The good news: an accessible contact form is mostly plain, well-structured HTML. Here is a checklist with code.

The accessible baseline

html
<form action="https://api.formiz.app/submit" method="POST" novalidate>
  <input type="hidden" name="access_key" value="YOUR_ACCESS_KEY">

  <div class="field">
    <label for="name">Your name</label>
    <input id="name" name="name" autocomplete="name" required aria-describedby="name-error">
    <p id="name-error" class="error" hidden></p>
  </div>

  <div class="field">
    <label for="email">Email address</label>
    <input id="email" name="email" type="email" autocomplete="email" required
           aria-describedby="email-hint email-error">
    <p id="email-hint" class="hint">We only use it to reply to you.</p>
    <p id="email-error" class="error" hidden></p>
  </div>

  <fieldset>
    <legend>How should we contact you?</legend>
    <label><input type="radio" name="preferred" value="email" checked> Email</label>
    <label><input type="radio" name="preferred" value="phone"> Phone</label>
  </fieldset>

  <div class="field">
    <label for="message">Message</label>
    <textarea id="message" name="message" rows="6" required aria-describedby="message-error"></textarea>
    <p id="message-error" class="error" hidden></p>
  </div>

  <!-- Honeypot: hidden from everyone, including assistive tech -->
  <div aria-hidden="true" style="position:absolute;left:-9999px">
    <label for="hp">Leave this empty</label>
    <input id="hp" type="checkbox" name="_honey" tabindex="-1" autocomplete="off">
  </div>

  <button type="submit">Send message</button>
  <p id="form-status" role="status" aria-live="polite"></p>
</form>

The checklist

1. Every field has a visible label

Placeholders are not labels: they disappear when typing, often have poor contrast and are not reliably announced. Use <label for> and keep it visible.

Radio buttons and checkboxes that answer one question go in a <fieldset> with a <legend>, so screen readers announce the question with each option.

3. Use autocomplete

autocomplete="name", email, tel, organization and so on let browsers and password managers fill fields. This helps everyone, and especially people with motor or cognitive disabilities. It is also a WCAG 2.1 success criterion (1.3.5 Identify Input Purpose).

4. Errors are specific, visible and announced

  • Write messages that say how to fix the problem: "Enter an email like name@example.com", not "Invalid input".
  • Put the message next to the field and connect it with aria-describedby.
  • Set aria-invalid="true" on the field.
  • On submit, move focus to the first invalid field.

The HTML5 validation guide has a script that does all four.

5. Do not rely on colour alone

A red border is invisible to some users. Pair it with text and, ideally, an icon. Keep text contrast at least 4.5:1 and borders of inputs at least 3:1 against the background.

6. Visible focus

Never remove focus outlines without replacing them:

css
input:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 3px solid #111;
  outline-offset: 2px;
}

7. Announce the result

After a fetch submission, write the outcome into an element with role="status" (or aria-live="polite"). Screen readers announce it without moving focus. If you replace the form entirely, move focus to the success message with tabindex="-1" and .focus().

8. Keep the honeypot away from assistive tech

Spam honeypots must be invisible to people and to screen readers and keyboards: aria-hidden="true" on the wrapper, tabindex="-1" on the input. Otherwise a blind user might fill it in and have their message discarded. More in stopping spam without a CAPTCHA.

9. Avoid inaccessible CAPTCHAs

Image puzzles exclude many users. Prefer invisible checks (honeypot, rate limiting, domain restriction). If you must add a challenge, choose one with an accessible, non-visual path.

10. Large enough targets

Make buttons and checkboxes at least 24×24 CSS pixels (WCAG 2.2, 2.5.8), and preferably 44×44 on touch devices. Clicking a <label> should toggle its checkbox, which is another reason to wrap inputs in labels.

Test it in five minutes

  1. Unplug the mouse and complete the form with Tab, Shift+Tab, Space and Enter.
  2. Turn on VoiceOver (Mac/iOS) or NVDA (Windows) and listen to each field's announcement.
  3. Submit it empty and check that errors are read out and focus moves.
  4. Zoom the page to 200% and check nothing overlaps.

After the submission

Accessibility does not stop at the form. Make sure your thank-you page has a clear heading and a link back, and that your reply email is readable. Formiz notification emails work on mobile and in dark mode, and the visitor's address is the reply-to, so answering is one tap.

Related: contact form best practices.

Get your form working in five minutes

Create a free Formiz key, add it to your form and receive submissions by email and Telegram. No server, no SMTP, no card.