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.
Kazi Khalid Hasan Tamim · 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-labelledbyortitle. 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 criterion | Level | What it asks of a form |
|---|---|---|
| 1.3.1 Info and Relationships | A | Labels, groups and required state exist in code, not just visually |
| 1.3.5 Identify Input Purpose | AA | Fields collecting the user's own data declare their purpose (autocomplete) |
| 2.4.6 Headings and Labels | AA | Labels describe what to enter |
| 2.5.3 Label in Name | A | The accessible name contains the visible label text |
| 3.3.1 Error Identification | A | The field in error is identified and the error is described in text |
| 3.3.2 Labels or Instructions | A | Labels or instructions are provided when input is required |
| 3.3.3 Error Suggestion | AA | When a fix is known, the error message suggests it |
| 3.3.4 Error Prevention (Legal, Financial, Data) | AA | Important submissions can be reviewed, corrected or reversed |
| 3.3.7 Redundant Entry | A | Information already entered isn't asked for again in the same process |
| 3.3.8 Accessible Authentication (Minimum) | AA | Sign-in doesn't depend on memorising or transcribing (allow paste and password managers) |
| 4.1.2 Name, Role, Value | A | Custom 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 checked | Result | Share |
|---|---|---|
| Fields with a programmatic label | 107 of 186 | 57.5 % |
| Fields named only by placeholder text | 52 of 186 | 28.0 % |
| Homepages with at least one unlabelled field | 55 of 91 | 60.4 % |
Homepages where axe-core's label rule failed | 13 of 91 | 14.3 % |
Personal-data fields (name, email, phone, address) with autocomplete | 10 of 55 | 18.2 % |
Fields marked required in code (required or aria-required) | 43 of 186 | 23.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.
<!-- ❌ Broken: the placeholder disappears on typing and is not a reliable name -->
<input type="email" placeholder="Email address"><!-- ✅ 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.
Group related options with fieldset and legend
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.
<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.
<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.
| Field | autocomplete token |
|---|---|
| Full name / first / last | name / given-name / family-name |
email | |
| Phone | tel |
| Company | organization |
| Street address / city / postcode | street-address / address-level2 / postal-code |
| Country | country-name |
| New password / existing password | new-password / current-password |
| SMS or email code | one-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.
<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.
<!-- ✅ 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:
<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 input | Enter your phone number using digits only, like 07700 900123 |
| Error | Card number is 15 digits; you entered 14 |
| Required | Enter your company name |
| Date invalid | Enter 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
- Click every label. Focus (or the checkbox state) should move to its field. If nothing happens, the label isn't connected.
- 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.
- 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.
- Submit it empty. Are errors shown in text, tied to each field, and is focus moved to the first error or the summary?
- Submit wrong formats. Does each message say how to fix the input?
- Let the browser autofill it. Name, email, phone and address should fill correctly. If they don't, the
autocompletetokens are missing or wrong. - Paste into the password and code fields. Blocking paste breaks password managers and fails WCAG 3.3.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.
#!/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:
$ 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 labelAll 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>oraria-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
Kazi Khalid Hasan Tamim · 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.
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 where your site stands
Run a free BugViso audit for SEO, speed, accessibility and AI search readiness — with fixes you can ship today.