Accessible Forms: How to Build and Test Them (WCAG 2.2)

Accessible forms for WCAG 2.2: build and test labels, errors, required fields and autocomplete, with a field-audit script and data from 186 real form fields.

· BugViso Team

14 min read

Accessible forms give every field a visible label tied to it in code, group related options, mark required fields in text, use autocomplete tokens for personal data, and report each error in words next to the field and to screen readers. Most failures are missing labels. In our test of 156 random homepages, 42.5 % of visible form fields had no programmatic label, and 28 % relied on placeholder text alone.

By the end you'll have the WCAG criteria a form must meet, field-by-field markup that passes them, an error pattern users can actually recover from, a 10-minute test protocol and a script that lists every field's accessible name.

Data used: 156 homepages that loaded cleanly, out of 268 domains drawn at random from the Tranco top-sites list (list 947V2, ranks 1,001 to 50,000), tested on 4 December 2026 with Playwright 1.52, Chromium 136 and axe-core 4.10.2 (WCAG 2.0 to 2.2 A and AA rules) at 1280 × 800 px. We excluded 112 domains that didn't resolve, failed TLS, timed out, returned an HTTP error or showed a bot challenge. Homepages only; sites aren't named. Fields are visible inputs, selects and textareas; a field counts as labelled if it has a <label>, aria-label, aria-labelledby or title. Population-wide figures come from the WebAIM Million 2026 report (data from February 2026).

Manual accessibility testing series: How to run a full accessibility audit · Keyboard testing · Screen reader testing · ARIA mistakes · Accessible forms (this post) · Reflow and zoom testing

The WCAG Criteria Every Form Must Meet

Eleven WCAG 2.2 success criteria apply to almost every form. Labels and names come first because they fail most often; errors come second because they decide whether a user finishes or gives up.

WCAG 2.2 criterionLevelWhat it asks of a form
1.3.1 Info and RelationshipsALabels, groups and required state exist in code, not just visually
1.3.5 Identify Input PurposeAAFields collecting the user's own data declare their purpose (autocomplete)
2.4.6 Headings and LabelsAALabels describe what to enter
2.5.3 Label in NameAThe accessible name contains the visible label text
3.3.1 Error IdentificationAThe field in error is identified and the error is described in text
3.3.2 Labels or InstructionsALabels or instructions are provided when input is required
3.3.3 Error SuggestionAAWhen a fix is known, the error message suggests it
3.3.4 Error Prevention (Legal, Financial, Data)AAImportant submissions can be reviewed, corrected or reversed
3.3.7 Redundant EntryAInformation already entered isn't asked for again in the same process
3.3.8 Accessible Authentication (Minimum)AASign-in doesn't depend on memorising or transcribing (allow paste and password managers)
4.1.2 Name, Role, ValueACustom controls expose their name, role and state

3.3.7 and 3.3.8 are new in WCAG 2.2 and hit checkout and login flows directly. The W3C's forms tutorial has worked examples for most of the rest.

What We Found in 186 Form Fields on 156 Homepages

91 of the 156 homepages (58.3 %) had at least one visible form field, usually a search box or a newsletter signup: 54 of the 91 had a single field. We checked every field for a programmatic label, and the fields that ask for personal data for autocomplete.

What we checkedResultShare
Fields with a programmatic label107 of 18657.5 %
Fields named only by placeholder text52 of 18628.0 %
Homepages with at least one unlabelled field55 of 9160.4 %
Homepages where axe-core's label rule failed13 of 9114.3 %
Personal-data fields (name, email, phone, address) with autocomplete10 of 5518.2 %
Fields marked required in code (required or aria-required)43 of 18623.1 %

The gap between the third and fourth rows matters. 79 fields had no label, but axe-core's label rule failed only 16 fields on 13 homepages, because axe-core accepts a non-empty placeholder as an accessible name. Placeholder-only fields pass the scan and still fail people: the hint disappears as soon as they type, and it's often too faint to read. A scanner's clean label result doesn't mean your forms are labelled; read the markup or run the script below.

The WebAIM Million 2026 found the same problem at scale: a third of the 6.9 form inputs on an average home page were unlabelled.

Build Accessible Forms Field by Field

Give every field a real label

A <label for> gives the field a name screen readers announce, makes the label clickable (a larger target for people with tremors), and keeps the instruction visible while the user types.

html
<!-- ❌ Broken: the placeholder disappears on typing and is not a reliable name -->
<input type="email" placeholder="Email address">
html
<!-- ✅ Fixed: visible, persistent, programmatically tied -->
<label for="email">Email address</label>
<input type="email" id="email" name="email" autocomplete="email">

Google's web.dev forms module makes the same point about placeholders: they aren't visually persistent, so they don't replace the label. Floating-label designs are fine as long as a real <label> is behind the animation.

A radio group's question is the label for the group, not for any one option. Without a <legend>, a screen reader user hears "Monthly, radio button, 1 of 2" and never hears what's being chosen.

html
<fieldset>
  <legend>Billing period</legend>
  <input type="radio" id="m" name="period" value="monthly" checked><label for="m">Monthly</label>
  <input type="radio" id="y" name="period" value="yearly"><label for="y">Yearly</label>
</fieldset>

Mark required fields in words, not only with a colour or an asterisk

Use the required attribute (which also sets the required state for assistive technology) and say it in text. Either label each required field, or say once at the top that all fields are required and mark the optional ones instead.

html
<label for="name">Full name <span aria-hidden="true">*</span><span class="visually-hidden">(required)</span></label>
<input id="name" name="name" autocomplete="name" required>

Declare what personal data each field collects

WCAG 1.3.5 asks fields that collect the user's own information to declare their purpose, and the HTML autocomplete attribute is how you do it. It lets browsers and password managers fill the form, which saves typing for everyone and is essential for people with motor or memory impairments. The token list lives in the HTML Standard's autofill section.

Fieldautocomplete token
Full name / first / lastname / given-name / family-name
Emailemail
Phonetel
Companyorganization
Street address / city / postcodestreet-address / address-level2 / postal-code
Countrycountry-name
New password / existing passwordnew-password / current-password
SMS or email codeone-time-code

Pair the token with the right type (email, tel, url) so phones show the matching keyboard.

Connect hints to their field

Format rules ("8+ characters, one number") belong under the label and in the field's accessible description, so they're read when the field receives focus.

html
<label for="pw">Password</label>
<input type="password" id="pw" autocomplete="new-password" aria-describedby="pw-hint" required>
<p id="pw-hint">At least 8 characters, including a number.</p>

Errors Users Can Actually Find and Fix

An accessible error is described in text, attached to its field, announced, and specific enough to act on. Red borders alone fail people who can't see colour; a message at the top of the page fails people who can't see the page.

html
<!-- ✅ Inline error: announced when the field is focused -->
<label for="email">Email address</label>
<input type="email" id="email" autocomplete="email" aria-invalid="true" aria-describedby="email-err">
<p id="email-err" class="error">Enter an email address in the format name@example.com</p>

For forms with more than a few fields, add an error summary at the top, move focus to it on submit, and link each item to its field:

html
<div role="alert" tabindex="-1" id="error-summary">
  <h2>There are 2 problems with your form</h2>
  <ul>
    <li><a href="#email">Enter an email address in the format name@example.com</a></li>
    <li><a href="#postcode">Enter a postcode, like SW1A 1AA</a></li>
  </ul>
</div>

The wording matters as much as the markup. WCAG 3.3.3 asks for a suggestion whenever you know what's wrong:

❌ Vague✅ Specific
Invalid inputEnter your phone number using digits only, like 07700 900123
ErrorCard number is 15 digits; you entered 14
RequiredEnter your company name
Date invalidEnter a date in the past, like 27 3 2007

Three more rules keep users in the form: keep everything they typed when the page reloads with errors, don't validate a field before they've left it, and never use a time limit on a form without a way to extend it.

How to Test a Form in 10 Minutes

  1. Click every label. Focus (or the checkbox state) should move to its field. If nothing happens, the label isn't connected.
  2. Tab through with the keyboard only. Every field, option and button should be reachable in a sensible order, with a visible focus indicator. Our keyboard accessibility testing guide covers this pass in detail.
  3. Listen with a screen reader. Each field should announce its label, type, required state and any hint. Radio groups should announce their legend. The screen reader testing guide lists the commands.
  4. Submit it empty. Are errors shown in text, tied to each field, and is focus moved to the first error or the summary?
  5. Submit wrong formats. Does each message say how to fix the input?
  6. Let the browser autofill it. Name, email, phone and address should fill correctly. If they don't, the autocomplete tokens are missing or wrong.
  7. Paste into the password and code fields. Blocking paste breaks password managers and fails WCAG 3.3.8.
  8. Zoom to 200 %. Labels must stay next to their fields, and nothing should overlap.

List Every Field's Accessible Name With a Script

The script prints each visible field with the name a screen reader will announce, its autocomplete token and whether it's required, and flags fields whose only "label" is a placeholder.

python
#!/usr/bin/env python3
"""List every visible form field with the name a screen reader announces,
whether that name is only a placeholder, its autocomplete token and required state.

Usage: python form_audit.py https://example.com/contact
Needs: pip install playwright && playwright install chromium
"""
import asyncio, sys
from playwright.async_api import async_playwright

FIELDS = r"""() => [...document.querySelectorAll('input,select,textarea')]
  .filter(e => !['hidden','submit','button','image','reset'].includes(e.type) && e.getBoundingClientRect().width > 0)
  .map(e => {
    const byId = id => (document.getElementById(id) || {}).textContent || '';
    const label = (e.labels && [...e.labels].map(l => l.textContent).join(' ').trim())
      || e.getAttribute('aria-label') || (e.getAttribute('aria-labelledby') || '').split(/\s+/).map(byId).join(' ').trim()
      || e.getAttribute('title') || '';
    return { field: `${e.tagName.toLowerCase()}[${e.type || ''}] ${e.name || e.id || ''}`.trim(),
      label: label.replace(/\s+/g, ' ').slice(0, 40), placeholder: e.getAttribute('placeholder') || '',
      autocomplete: e.getAttribute('autocomplete') || '', required: e.required || e.getAttribute('aria-required') === 'true' };
  })"""

async def main(url):
    async with async_playwright() as pw:
        page = await (await pw.chromium.launch()).new_page()
        await page.goto(url, wait_until="domcontentloaded")
        await page.wait_for_timeout(2000)
        rows = await page.evaluate(FIELDS)
    print(f"{'field':<34} {'accessible name':<40} {'autocomplete':<16} req  problem")
    for r in rows:
        problem = "NO LABEL" if not r["label"] else ""
        if not r["label"] and r["placeholder"]:
            problem = "placeholder only"
        print(f"{r['field'][:33]:<34} {r['label'] or '-':<40} {r['autocomplete'] or '-':<16} {'yes' if r['required'] else 'no ':<4} {problem}")
    print(f"\n{len(rows)} fields · {sum(1 for r in rows if not r['label'])} without a label")

asyncio.run(main(sys.argv[1]))

Output from our own homepage, unedited:

text
$ python form_audit.py https://bugviso.com
field                              accessible name                          autocomplete     req  problem
input[text] hero-domain            Company domain                           -                no
input[text] wl-company             Company name                             -                no
input[color]                       Pick a brand color                       -                no
input[text] wl-color               Brand color                              -                no
input[url] wl-logo                 Logo URL (optional)                      -                no
input[range] plan-audits           How many audits do you run a month?      -                no
input[text] closing-domain         Website to audit                         -                no

7 fields · 0 without a label

All seven fields have a name. None collects the visitor's own personal data, so none needs an autocomplete token under 1.3.5. On a contact or checkout form, that column is where problems show up first.

How BugViso Checks Form Labels on Every Page

BugViso runs axe-core's form rules on every page it crawls: label (an input with no accessible name), select-name, input-button-name (an image or submit button with no name), aria-input-field-name and aria-toggle-field-name (custom fields and switches with no name), and autocomplete-valid (a token that isn't in the HTML list, which breaks 1.3.5). Each finding carries the selector and the failing HTML, and they're grouped by rule, so a newsletter field in the site footer shows up once with every page it appears on.

Scanners can't submit your form, read your error messages or judge whether "Invalid input" helps anyone, so the 10-minute test above still matters. Use the WCAG accessibility audit to find every unlabelled field across the site first, then test the forms that carry revenue by hand.

Edge Cases That Fail Audits

  • Search boxes with only an icon button. The field still needs a name: a visually hidden <label> or aria-label="Search" on the input, and a name on the button.
  • CAPTCHAs. A puzzle with no alternative fails 3.3.8. Offer a non-cognitive route (an email link, an audio option, or a risk-based check that shows no puzzle to most users).
  • Multi-step checkouts. Asking for the billing address again after the shipping address fails 3.3.7 unless there's a "same as shipping" option.
  • Custom selects and date pickers. They need the full keyboard model and correct roles. The native <select> and <input type="date"> are usually the safer choice.
  • Disabled submit buttons. A button that stays disabled until the form is valid gives no reason why. Keep it enabled and show the errors on submit.
  • Character counters. "42 characters remaining" should be in a polite live region that updates after typing pauses, not on every keystroke.

Frequently Asked Questions

Is placeholder text enough as a form label?

No. Placeholder text disappears as soon as the user types, often has low contrast, and isn't reliably used as the accessible name by every browser and screen reader combination. WCAG 3.3.2 needs labels or instructions that stay available. Use a visible <label> and, if you like, a placeholder with an example value.

Do I need fieldset and legend for radio buttons?

Yes, whenever a group of radio buttons or checkboxes answers one question. The <legend> is announced with the options, so screen reader users know what they're choosing. A single checkbox ("I agree to the terms") doesn't need one; its own label is enough.

How should required fields be marked for accessibility?

Add the required attribute (or aria-required="true" on custom controls) so assistive technology announces the state, and indicate it in visible text, not colour alone. An asterisk works if you explain it once at the top of the form; marking only the optional fields "(optional)" is clearer when most fields are required.

What autocomplete values does WCAG require?

WCAG 1.3.5 (Level AA) applies to fields that collect information about the user, such as name, email, phone, address, birthday and organisation, and asks that their purpose be programmatically determinable. In HTML, that means the matching autocomplete token: name, email, tel, street-address, postal-code and so on. Fields about other people or other things don't need it.

How do I make form error messages accessible?

Describe the error in text next to the field, connect it with aria-describedby, set aria-invalid="true", and move focus to the first error or to an error summary when the form is submitted. Make each message say how to fix the input, keep the user's entries, and never rely on a red border alone.

Can I block pasting in password or verification fields?

Don't. Blocking paste stops password managers from working and forces users to memorise or retype codes, which fails WCAG 2.2's 3.3.8 Accessible Authentication (Minimum). Use autocomplete="current-password", new-password or one-time-code so browsers can fill these fields.

Label First, Then Everything Else

Labels are the highest-yield fix in this guide: they repair the screen reader announcement, the click target and the instruction in one change. Fix every unlabelled field, then work through errors and autofill, and let an automated audit find the unlabelled fields across the whole site so you don't have to open every page.

Written by

· BugViso Team

Kazi writes BugViso’s guides on website audits, Core Web Vitals, technical SEO, accessibility and AI search. The data in them comes from audits BugViso runs in a real Chromium browser, including our 219-site study of website health.

Found this useful? Share it.

Summarise with AI

Open this guide in your assistant.

Follow BugViso

New guides and audit data as we publish them.

AI visibility tracker

Is your brand in AI answers?

See how often AI assistants mention you, cite your site and rank you against your competitors.

  • ChatGPT
  • Gemini
  • Perplexity
  • Claude
  • AI Overviews
See how it works

See where your site stands

Run a free BugViso audit for SEO, speed, accessibility and AI search readiness — with fixes you can ship today.