Accessible forms: what everyone must be able to fill in
AccessibilityHow labels, field types, autocomplete and error messages make a form usable for everyone, what the CAPTCHA has to do with it and how to check your own in five minutes.
13 min read
By Timo Wessels Published
A form is accessible if everyone can fill it out and submit it without help. That applies with a screen reader (a program that reads the page aloud), with the keyboard only, on the phone or with a learning difficulty. It takes little:
Every field has a visible, technically linked label, groups have a heading, errors are reported as text at the field and say what to do.
On top come the right field type and autocomplete, which make typing easier or save it entirely. Almost all of this is standard HTML and costs next to nothing in a new build.
The most important points first:
- Every field has a visible label that is technically linked to the field.
- Errors stand as text at the field and say what to do.
- The right field type and
autocompletesave typing.
The label: for and id
A form consists of the <form> element, the fields, their labels and the submit button. The decisive point is the connection between label and field. The W3C forms tutorial puts it briefly: the for attribute of the <label> must exactly match the id of the field.
<label for="email">Email address</label>
<input type="email" id="email" name="email" autocomplete="email">
Only this link turns two elements standing side by side into a pair that a screen reader also recognises as belonging together. On the side, the label becomes clickable and so enlarges the area with which you hit the field. You cannot see the difference in the form: a field with a text above it looks just like a field with a linked label. It only becomes audible with the screen reader.
The link falls under criterion 1.3.1 “Info and Relationships”, Level A, the presence of a label under 3.3.2 “Labels or Instructions”, also Level A. These are criteria of the WCAG, the international guidelines for accessible websites. Whoever builds their own controls from div and span instead of standard fields must supply name, role and state themselves (4.1.2, Level A). Standard fields do that by themselves according to the W3C, one more reason to stay with them.
The placeholder is not a label
The most common mistake looks the tidiest: no label above the field, instead a grey text in the field itself. The W3C tutorial names problems:
- It disappears as soon as someone starts to type. Whoever comes back after a distraction sees a half-filled field with no hint of what belonged in it.
- It is too pale. Browsers usually show it with a contrast that does not reach the minimum of the WCAG.
- Assistive technologies do not treat it as a label.
Placeholders may stay, as an example of a format. As a replacement for the label they are no good.
The field type decides the phone keyboard
This is the point with the greatest everyday benefit and the least effort. The type attribute controls which on-screen keyboard a mobile browser shows, and most types check the input at the same time:
| Field | type |
What the user gets |
|---|---|---|
| Phone number | tel |
Phone keypad with digits |
email |
Keyboard with @, format check |
|
| Website | url |
Keyboard for addresses, format check |
| Search | search |
Search field, often with a fitting keyboard |
| Quantity | number |
Numeric keyboard |
| Date | date |
Date picker, different depending on browser and system |
A phone field with type="text" means: the user gets a letter keyboard, looks for the shift key for digits and carries on typing, with every form. type="tel" by the way checks no format, because phone numbers are too different worldwide. MDN calls it functionally identical to a normal text field, the advantage lies in the keyboard.
Caution with number: MDN advises using it only for numbers where counting up and down makes sense. It is not suitable for values that happen to consist only of digits, such as postcodes or card numbers. For those you use type="text" with inputmode="numeric". The W3C warns for the same reason: postcodes contain letters in some countries.
autocomplete saves the typing entirely
The field type says what kind of data is expected. autocomplete says what the field is for: given-name for the first name, family-name for the surname, email, tel, street-address, postal-code. new-password tells the password manager that a new password is being created here, current-password that the saved one should be filled in.
Criterion 1.3.5 “Identify Input Purpose”, Level AA, requires that the purpose of fields collecting information about the person can be recognised in the code. The W3C explains that some people with cognitive disabilities may not understand the purpose of a field from the label alone. MDN confirms that valid autocomplete values satisfy the criterion. For everyone else it is seconds saved per field. Important: only the defined values count. An invented value does not satisfy the criterion.
Required fields: required and a word
Whether a field is required is a business decision: does the enquiry really need a phone number, or is the field just there because it always was?
Once the decision is made, it belongs in the HTML. The required attribute prevents submitting while the field is empty and tells assistive technology that it is required. MDN recommends it for fields that need a value. aria-required="true" reports the same information only to assistive technology and checks nothing. It is meant for self-built controls that are not HTML fields.
A red asterisk or a red border alone is not enough, because colour does not carry the information for everyone. MDN names text or a symbol as the usual marking, such as “(required)” in the label, or an asterisk with an explanation above the form.
Grouping what belongs together
For radio buttons a group label is necessary. Three options without a question above them are three unrelated words. The W3C tutorial says: related controls belong in a <fieldset>, and <legend> gives the group its heading. This applies to radio button and checkbox groups.
<fieldset>
<legend>How should we reach you?</legend>
<input type="radio" id="k-mail" name="contact" value="mail">
<label for="k-mail">By email</label>
<input type="radio" id="k-tel" name="contact" value="tel">
<label for="k-tel">By phone</label>
</fieldset>
Screen readers handle the legend differently: depending on the setting they read it with every field, once, or rarely not at all. That is why the W3C advises keeping the legend as short as possible and wording the individual labels so that they are understandable without the legend. The same device orders long forms: personal details in one block, contact data in the next.
Error messages that help
“Error” is not a message. The criteria require three things:
- The error is there as text (3.3.1, Level A). A red border may be there in addition but does not replace the text.
- The message says what to do if a correction is known (3.3.3, Level AA). “Enter the date as DD.MM.YYYY” instead of “Invalid input”.
- The message is linked to the field. The W3C technique ARIA21 sets
aria-invalid="true"on the field once the check has failed. Before that the attribute should not be set to “true”. Connect the field througharia-describedbywith the message text. Then the screen reader reads the message out as soon as the field gets focus.
The W3C tutorial also recommends listing all errors at the top above the form after submitting, with a heading of their own. Set the focus on the first faulty field. For some fields it makes sense to check already when leaving the field instead of only on submitting. The success message afterwards belongs in an area that assistive technology recognises as a status message, for example with role="status", so that a screen reader announces it without the focus having to jump (4.1.3, Level AA).
Being forgiving is better than reporting well. The W3C advises accepting as many notations as possible: phone numbers are written with different separators and groupings. And it warns against type="number" for postcodes, because they contain letters in some countries. A form that accepts such input and tidies it up itself produces no error at all. The check in the browser, by the way, does not replace the one on the server: the W3C writes that client-side validation alone does not ensure security.
Help before the error happens
If a field expects a particular format, it should be written there: best in the label or as text under the field, linked through aria-describedby. Then the explanation is read out after the label and not just there. For file uploads that means: name the allowed formats and maximum size before someone uploads a file that is too large. That is my practice.
The W3C urges moderation here: too much instruction can harm as much as too little. One hint per field, where it is needed, is enough.
For forms with consequences: have them checked
Criterion 3.3.4, Level AA, applies to forms that trigger a legal commitment or a payment, change or delete stored user data, or submit test answers. At least one of these must then apply:
- Reversible: the submission can be taken back.
- Checked: the entries are checked for errors and the user can correct them.
- Confirmed: before the final submission there is an overview for checking and correcting.
For a contact form this is not required. For an order, a paid booking or a cancellation it is.
The CAPTCHA at the end
Two topics meet here at an unpleasant spot. A CAPTCHA is a test meant to tell humans from programs.
Accessibility: in its note on the inaccessibility of CAPTCHAs the W3C records that the classic CAPTCHA with distorted characters is a problem for blind people, because the screen reader cannot read the image. The audio alternative is also distorted and hard for many to understand. The W3C also says such a CAPTCHA is increasingly ineffective as a security measure, because programs crack it. Whoever puts such a CAPTCHA in front of their contact form therefore loses prospects without noticing.
Data protection: the Austrian Federal Administrative Court decided on 13 September 2024 (W298 2274626-1/8E) that Google reCAPTCHA is technically not necessary for operating a website and therefore needs consent. The IT-Recht Kanzlei, which reports on it, sums it up like this: if a service sets cookies that are not technically necessary, consent is required. Whether the same applies in Germany is for data protection advice to clarify. Practically it is a dilemma: whoever loads reCAPTCHA only after consent has no protection at all for everyone who rejects the cookie banner. That is my assessment.
As an alternative without a puzzle for the user, the W3C names, among others, the honeypot: a field only robots see, because it is hidden from humans by CSS. It is successful enough, the W3C says, that several content management systems such as Drupal and several commercial WordPress plugins offer it. Whether another CAPTCHA service may be used without consent is for data protection advice to clarify.
How to check it yourself
Five tests, none needs a tool:
- The click test. Click on the label text above a field. If the cursor jumps into the field, the link is there. If nothing happens, it is missing. This works with every form, including other people’s.
- The keyboard test. Put the mouse away. Tab through the form, fill in every field, submit. Do you get everywhere? Can you see at every step where you are?
- The error test. Submit the form wrongly on purpose: required field empty, email without
@. Does the message stand as text at the field? Does it say what to do? Does the focus land on the error? - The phone test. On the phone, tap into each field in turn. Does the phone field bring the keypad, the email field a keyboard with
@? If the same letter keyboard comes everywhere, the field types are missing. - The autofill test. Click into the name field. Does the browser offer a suggestion? If not,
autocompleteis probably missing.
Whoever wants to know more adds a screen reader. NVDA is free for Windows.
What you can do
- A visible label on every field, linked through
forandid. Placeholders only as a format example. - Set field types:
tel,email,url,date.numberonly for real quantities. autocompleteon all fields with personal details.- Required fields with
requiredand marked in the text, not only by colour. - Radio buttons and checkbox groups in
<fieldset>with<legend>. - Error messages as whole sentences at the field, with
aria-describedbyandaria-invalid="true", and a success message withrole="status". - Write format hints and link them as well.
- Replace the graphic CAPTCHA, in the simplest case with a honeypot.
- And the point that brings the most: fewer fields. Every field you drop you need not label, not check, and nobody has to fill it in. That is my experience.
What the law requires
According to the federal portal, the Barrierefreiheitsstärkungsgesetz (BFSG, the German accessibility act) applies to services provided to consumers after 28 June 2025, including services in electronic commerce. Order, booking and sign-up forms are therefore at the centre, because the actual transaction takes place there. Micro-enterprises with fewer than ten employees and an annual turnover or balance sheet total of at most 2 million euros are partly exempt from the law. The yardstick is the European standard EN 301 549. According to the federal government, many of its requirements refer to the WCAG criteria, and it describes level AA as the standard to be reached for good accessibility. All criteria in this article belong to levels A and AA of the WCAG. Whether your business is affected is for legal advice to clarify, not for a technical check. Regardless of that: in a new build these measures cost almost nothing, afterwards considerably more. That is my assessment.
Sources
- W3C WAI, Forms Tutorial: Labeling Controls —
forandid, larger click area: w3.org(external site: w3.org) - W3C WAI, Forms Tutorial: Form Instructions — placeholders, hints: w3.org(external site: w3.org)
- W3C WAI, Forms Tutorial: Grouping Controls —
fieldsetandlegend, screen reader behaviour: w3.org(external site: w3.org) - W3C WAI, Forms Tutorial: Validating Input — forgiving checks, postcodes, validation on the server: w3.org(external site: w3.org)
- W3C WAI, Forms Tutorial: User Notifications — error list, focus on the first faulty field, check on leaving: w3.org(external site: w3.org)
- W3C, Understanding WCAG 2.2: Info and Relationships — 1.3.1: w3.org(external site: w3.org)
- W3C, Understanding WCAG 2.2: Identify Input Purpose — 1.3.5: w3.org(external site: w3.org)
- W3C, Understanding WCAG 2.2: Error Identification — 3.3.1: w3.org(external site: w3.org)
- W3C, Understanding WCAG 2.2: Labels or Instructions — 3.3.2: w3.org(external site: w3.org)
- W3C, Understanding WCAG 2.2: Error Suggestion — 3.3.3: w3.org(external site: w3.org)
- W3C, Understanding WCAG 2.2: Error Prevention (Legal, Financial, Data) — 3.3.4, three ways: w3.org(external site: w3.org)
- W3C, Understanding WCAG 2.2: Name, Role, Value — 4.1.2: w3.org(external site: w3.org)
- W3C, Understanding WCAG 2.2: Status Messages — 4.1.3: w3.org(external site: w3.org)
- W3C, Technique ARIA21 —
aria-invalidwitharia-describedby: w3.org(external site: w3.org) - W3C, Inaccessibility of CAPTCHA — graphic and audio CAPTCHAs, honeypot: w3.org(external site: w3.org)
- MDN, input type tel — phone keypad, no format check: developer.mozilla.org(external site: developer.mozilla.org)
- MDN, input type number — only for real numbers, not for postcodes: developer.mozilla.org(external site: developer.mozilla.org)
- MDN, input type date — date picker depending on browser: developer.mozilla.org(external site: developer.mozilla.org)
- MDN, inputmode — on-screen keyboards: developer.mozilla.org(external site: developer.mozilla.org)
- MDN, autocomplete — values and relation to 1.3.5: developer.mozilla.org(external site: developer.mozilla.org)
- MDN, aria-required — precedence of
required, marking not only by colour: developer.mozilla.org(external site: developer.mozilla.org) - IT-Recht Kanzlei, BVwG Österreich zu Google reCAPTCHA — 13.09.2024, W298 2274626-1/8E, consent required: it-recht-kanzlei.de(external site: it-recht-kanzlei.de)
- NV Access, About NVDA — free screen reader for Windows: nvaccess.org(external site: nvaccess.org)
- Portal Barrierefreiheit des Bundes, Barrierefreiheitsstärkungsgesetz — applies from 28.06.2025, micro-enterprises: barrierefreiheit-dienstekonsolidierung.bund.de(external site: barrierefreiheit-dienstekonsolidierung.bund.de)
- Portal Barrierefreiheit des Bundes, WCAG und EN 301 549 — the standard’s reference to the WCAG, level AA: barrierefreiheit-dienstekonsolidierung.bund.de(external site: barrierefreiheit-dienstekonsolidierung.bund.de)
- Own practice — the five tests, hints on file uploads, fewer fields.