Labels, Fieldsets, and Accessible Forms: The Structure Screen Readers Actually Need
Accessible forms with plain HTML: labels, fieldset and legend, hints and errors with aria-describedby, required fields, and error summaries.
<label> tied to it, groups of radios or checkboxes sit inside a <fieldset> with a <legend>, hints and errors are connected with aria-describedby, and required and invalid states are exposed, not just colored. All of it is plain HTML.
Turn on VoiceOver or NVDA and tab through a typical sign-up form. You hear “edit text”, “edit text”, “edit text, password”, “radio button, not checked, 1 of 3”. No field names, because the labels are styled divs. No question for the radio buttons, because the heading above them is not connected to anything. The red error text under the email field is never announced. The form looks fine. To a screen reader user it is a set of blanks.
Accessible forms are forms whose controls expose a correct accessible name (what the field is), role (what kind of control it is), state (checked, required, invalid) and description (hints and errors) to assistive technology. The right input type takes care of the role. This article covers the rest, and almost all of it comes from three elements: label, fieldset and legend.
Why does every control need a label?
A <label> gives a control its accessible name and, as a bonus, makes the label text clickable, which enlarges the target for a small checkbox or radio button. There are two ways to associate them.
<!-- Explicit: for matches the input's id -->
<label for="full-name">Full name</label>
<input id="full-name" name="name" type="text" autocomplete="name">
<!-- Implicit: the input is inside the label -->
<label>
<input type="checkbox" name="terms" required>
I agree to the terms of service
</label>
Both work in current browsers and screen readers. The explicit form is more reliable with some older assistive technology and lets you place the label anywhere in the layout, so I use it for text fields and the implicit form for checkboxes and radios, where wrapping keeps the markup short. Each id must be unique on the page; a duplicate ID from a reused component is one of the most common reasons a label silently stops working.
Placeholders are not labels
<!-- Looks clean, fails users -->
<input type="email" placeholder="Email address">
Placeholder text disappears as soon as someone types, so users forget what the field was for and cannot check their answers before submitting. It usually has low contrast. Browser autofill replaces it immediately. Some screen readers announce it, others do not. Use a visible label, and if you want an example format, put it in the label or a hint: “Email, for example name@company.com”.
When the label must be hidden
A search field next to a magnifying-glass button is a common case where a visible label would clutter the design. Keep a real label and hide it visually, so it stays in the accessibility tree:
<label for="q" class="visually-hidden">Search products</label>
<input id="q" name="q" type="search">
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
Do not use display: none or hidden for this; they remove the label from the accessibility tree too. aria-label="Search products" also works, but a real label element is the more dependable default.
Keep the visible text in the name
WCAG 2.5.3, Label in Name, requires that a control’s accessible name contains the text people can see. Voice control users say what they see: “click Send message”. If an aria-label overrides the visible text with “Submit contact form”, that command fails. When you add aria-label, start it with the visible words.
When do you need fieldset and legend?
A set of radio buttons answers one question. Each radio has its own label (“Standard”, “Express”), but the question (“Delivery speed”) belongs to the group. <fieldset> creates the group, and <legend> names it.
<fieldset>
<legend>Delivery speed</legend>
<label><input type="radio" name="delivery" value="standard" checked> Standard, 3 to 5 days</label>
<label><input type="radio" name="delivery" value="express"> Express, next day</label>
</fieldset>
Screen readers announce the legend when focus enters the group, so the user hears “Delivery speed, group. Standard, 3 to 5 days, radio button, checked, 1 of 2”. Without the fieldset, they hear “Standard, radio button” with no idea what question it answers.
Use a fieldset for:
- Every radio group and every set of related checkboxes.
- Related text fields that only make sense together, such as day, month and year of a date, or the parts of an address.
- Major sections of a long form, such as “Shipping address” and “Billing address”, where the legend tells users which address they are filling in.
Keep legends short, because some screen readers repeat the legend before every control in the group. And do not nest fieldsets deeply; one level of grouping is usually enough.
Fieldsets used to be hard to style, which is why many teams replaced them with divs. Modern browsers let you reset the default border and padding and style the legend like any heading:
fieldset { border: 0; padding: 0; margin: 0 0 1.5rem; min-width: 0; }
legend { font-weight: 600; margin-bottom: 0.5rem; padding: 0; }
The min-width: 0 line overrides a default min-width: min-content that makes fieldsets refuse to shrink in narrow layouts.
How do hints and errors work with aria-describedby?
A hint such as “Must be at least 12 characters” is useless to a screen reader user if it is just a paragraph near the field. aria-describedby connects it, so it is read after the label and role.
<label for="password">Password</label>
<p id="password-hint" class="hint">At least 12 characters. Spaces are allowed.</p>
<input id="password" name="password" type="password"
autocomplete="new-password" minlength="12" required
aria-describedby="password-hint password-error">
<p id="password-error" class="error" hidden></p>
The attribute accepts several IDs in order. When validation fails, fill in the error text, remove hidden and set aria-invalid="true" on the input. The screen reader then announces “Password, secure edit text, invalid entry, required. At least 12 characters. Password is too short.” Placing the hint above the field, as here, also helps sighted users, who read it before typing rather than after.
Errors that everyone notices
- Do not rely on color. A red border alone fails WCAG 1.4.1. Add text and an icon.
- Write specific messages. “Enter a date in the past” helps; “Invalid input” does not.
- On submit, show an error summary. A box at the top of the form listing each error as a link to its field, focused with JavaScript after a failed submission, tells keyboard and screen reader users immediately that something went wrong and where.
- Keep the user’s input. Never clear a form because one field failed.
<div class="error-summary" role="alert" tabindex="-1">
<h2>There are 2 problems with your details</h2>
<ul>
<li><a href="#email">Enter an email address in the correct format</a></li>
<li><a href="#password">Password must be at least 12 characters</a></li>
</ul>
</div>
How should you mark required fields?
Add the required attribute; it exposes the required state to assistive technology and enables built-in validation. Then make the requirement visible in text. If most fields are required, mark the optional ones instead (“Company name (optional)”), which is less noisy than a row of asterisks. If you do use an asterisk, explain it once at the top of the form, because a bare asterisk means nothing to many users.
A pre-launch form check
- Click every label. Focus should land in its field, and checkboxes should toggle.
- Tab through the whole form with a screen reader on. Every field should announce a name that makes sense on its own.
- Check that each radio group announces its question.
- Submit with errors. Is the problem announced, and can you get to each broken field from the summary?
- Zoom to 200%. Labels and fields should stay together, not drift apart in a two-column layout.
- Inspect the accessibility tree in DevTools for any input whose name is empty.
Frequently Asked Questions
Is a placeholder enough instead of a label?
No. Placeholders disappear when the user types, usually have poor contrast, are replaced by autofill, and are not announced consistently by screen readers. Every field needs a visible label; use a placeholder only for an optional example.
When should I use fieldset and legend?
Use them for every group of radio buttons or checkboxes, for related fields that only make sense together such as the parts of a date or address, and for major sections of long forms. The legend names the group and is announced when focus enters it.
How do I make form errors accessible?
Put the error text in an element linked to the field with aria-describedby, set aria-invalid=”true” on the field, describe the problem in words rather than color alone, and show an error summary at the top of the form after a failed submit.
Should I use aria-label or a label element?
Prefer a visible label element. Use a visually hidden label when the design truly has no room for visible text. Use aria-label only when neither is possible, and make sure it begins with any visible text on the control.
Structure is the feature
None of this requires a framework, a plugin or even CSS. It is a label for every field, a fieldset for every group and an ID reference for every hint and error. Build forms this way from the start and they work for keyboard, voice and screen reader users without any special mode, and they are clearer for everyone else too. For the full reference, see the W3C WAI forms tutorial and the MDN fieldset reference. Related reading on this site: native form validation and ARIA landmarks.
Originally posted on 9 May 2023 and post last modified on 9 May 2023