Related checkboxes or radio buttons should be grouped together.
Description
A short run of checkboxes or radio buttons reads as a single question only when the page says so. Screen reader users move through form controls with one keystroke and hear each input announced in isolation unless the group carries a programmatic boundary, so three shipping options or five colour swatches arrive as unrelated toggles with no hint that picking one rules the others out.
Grouping encodes that relationship in the markup: a <fieldset> wraps the related controls and a <legend> names the question, so assistive technology announces the question before each option and lets the user skip the group in a single command. Grouped radios also gain native arrow-key navigation. This is exactly what WCAG 2.2 success criterion 1.3.1, Info and Relationships asks for – structure that is only visible on screen must be available in code, not inferred from spacing and proximity.
Disabilities impacted
- Screen reader users: they lose the question that frames each option, so a bare list of unlabelled-sounding toggles gives no clue what is being asked or whether one answer excludes the others.
- Cognitive disabilities: unlabeled groups force the reader to infer the question from surrounding copy, increasing the risk of skipped, duplicated or contradictory selections on long forms.
- Motor disabilities: users who navigate with the keyboard, switch access or speech input lose the native arrow-key and grouping behaviour of a proper radio set and have to tab through every option individually.
- Vision impairments: screen magnifier users who read a narrow column see only one or two options at a time, so the visual boundary of a fieldset is often their only cue that a larger question exists.
Why it matters
Forms are where accessibility failures become business failures. A mis-grouped question is submitted with the wrong value or no value at all, and the user is never told why – the error surfaces after submission with no field context to attach it to. Grouping the controls makes validation messages meaningful, reduces abandoned checkouts, and keeps the interface predictable for keyboard-only and switch users.
It is also a compliance obligation. WCAG 1.3.1 is a Level A criterion, the part of the standard that cannot be traded off, and it is the fastest Level A item to fail in an automated scan. Legal exposure follows: ADA title obligations in the United States and the European Accessibility Act both point back to harmonised WCAG conformance, so a grouping defect on a checkout or booking flow is a defect in the public interface, not a cosmetic detail.
Coding problems and solutions
Common coding problems
- Shared name without a fieldset: every input carries the same
nameattribute but no<fieldset>wraps them, so the mutual exclusivity is invisible in the accessibility tree. - Legend replaced by a styled heading: a
<h3>or<span>sits above the group where a<legend>belongs, and nothing programmatically binds the label to the set. - Fieldset with no legend: the wrapper exists, but the group is unnamed, so screen reader users hear options with no question.
- Legend styled as visible body text: removing the default legend rendering via CSS is fine, but removing it from the accessibility tree with
display: noneorvisibility: hiddendeletes the accessible name. - ARIA-only grouping:
role="radiogroup"witharia-labelis valid ARIA but needs the fullrole="radio",aria-checkedand keyboard contract hand-built, and it is invisible to this audit, which looks for a fieldset ancestor. - Groups injected without the wrapper: JavaScript appends inputs after the initial scan or after a fetch, and the template that builds them never includes the fieldset and legend.
- Namespaces and single controls: a lone checkbox in the group gets a
nameanyway, or radio options drift to slightly different names such ascolour-1,colour-2, which destroys grouping at the HTML level.
How to fix it
Radio button sets
Put every radio that shares a name inside one fieldset, and use the legend for the question text, not for a decorative heading. Only one radio in a same-named set should carry checked.
<fieldset class="form-group">
<legend class="col-form-label pt-0">Preferred contact method</legend>
<div class="form-check">
<input class="form-check-input" type="radio" name="contact" id="contact-email" value="email" checked>
<label class="form-check-label" for="contact-email">Email</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="contact" id="contact-phone" value="phone">
<label class="form-check-label" for="contact-phone">Phone</label>
</div>
</fieldset><!-- No fieldset, no legend: the question exists only as a heading -->
<h3 class="h5">Preferred contact method</h3>
<div class="form-check">
<input class="form-check-input" type="radio" name="contact" id="contact-email" value="email" checked>
<label class="form-check-label" for="contact-email">Email</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="contact" id="contact-phone" value="phone">
<label class="form-check-label" for="contact-phone">Phone</label>
</div>[/escape]Checkbox groups and nested option lists
Checkboxes that answer one multi-select question are grouped the same way. When a group contains sub-questions, nest a second fieldset inside the first – each level needs its own legend, and a purely visual divider is not a substitute.
<fieldset class="border rounded p-3 mb-4">
<legend class="float-none w-auto px-2 fs-6">Delivery speed</legend>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="delivery" id="delivery-standard" value="standard" checked>
<label class="form-check-label" for="delivery-standard">Standard (3-5 days)</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="delivery" id="delivery-express" value="express">
<label class="form-check-label" for="delivery-express">Express (next day)</label>
</div>
<fieldset class="mt-3 ms-3">
<legend class="float-none w-auto px-2 fs-6">Leave with neighbour?</legend>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="neighbour" id="neighbour-yes" value="yes">
<label class="form-check-label" for="neighbour-yes">Yes, I authorise it</label>
</div>
</fieldset>
</fieldset><!-- Options answered to different questions, dumped into one unnamed bucket -->
<div class="border rounded p-3">
<p class="fw-bold">Delivery</p>
<input type="checkbox" name="delivery" id="delivery-standard" value="standard">
<label for="delivery-standard">Standard</label>
<input type="checkbox" name="delivery" id="delivery-express" value="express">
<label for="delivery-express">Express</label>
<input type="checkbox" name="neighbour" id="neighbour-yes" value="yes">
<label for="neighbour-yes">Leave with neighbour</label>
</div>[/escape]Groups rendered by JavaScript
Client-rendered groups must be grouped in the template that produces them, not patched afterwards. Write the fieldset and legend into the markup string, and if options arrive asynchronously, insert the finished fragment – wrapper included – in one operation so there is no frame where ungrouped controls exist.
const buildOptionGroup = (options, name, legendText) => {
const fieldset = document.createElement('fieldset');
const legend = document.createElement('legend');
legend.textContent = legendText;
fieldset.append(legend);
options.forEach((option) => {
const wrapper = document.createElement('div');
const input = document.createElement('input');
const label = document.createElement('label');
wrapper.className = 'form-check';
input.type = 'radio';
input.name = name;
input.id = `${name}-${option.value}`;
input.value = option.value;
label.className = 'form-check-label';
label.htmlFor = input.id;
label.textContent = option.label;
wrapper.append(input, label);
fieldset.append(wrapper);
});
return fieldset;
};
const mountGroup = async (endpoint, container) => {
try {
const response = await globalThis.fetch(endpoint);
const options = await response.json();
container.replaceChildren(buildOptionGroup(options, 'delivery', 'Delivery speed'));
} catch (err) {
console.error('Could not render delivery options', err);
}
};const mountGroup = async (endpoint, container) => {
try {
const response = await globalThis.fetch(endpoint);
const options = await response.json();
options.forEach((option) => {
const input = document.createElement('input');
input.type = 'radio';
input.name = 'delivery';
input.id = `delivery-${option.value}`;
input.value = option.value;
container.append(input);
});
} catch (err) {
console.error('Could not render delivery options', err);
}
};
// Fields appended one by one, legend added later by a timer.
globalThis.setTimeout(() => {
const legend = document.createElement('strong');
legend.textContent = 'Delivery speed';
container.prepend(legend);
}, 500);Card-style groups and custom styling
Designers usually want the default fieldset chrome gone. Keep the element, hide the legend visually with a screen-reader-only utility rather than display: none, and rebuild the box with borders or flex on the fieldset itself. ARIA-only grouping is a last resort: it must hand-build roles, state and keyboard handling, and this audit cannot confirm it exists.
<fieldset class="option-cards border-0 p-0 m-0 d-flex gap-2">
<legend class="visually-hidden">Case size</legend>
<div class="card option-card flex-fill">
<div class="card-body">
<input class="form-check-input" type="radio" name="case-size" id="case-small" value="small" checked>
<label class="form-check-label fw-bold" for="case-small">Small</label>
<p class="card-text mb-0">Fits a phone and charger.</p>
</div>
</div>
<div class="card option-card flex-fill">
<div class="card-body">
<input class="form-check-input" type="radio" name="case-size" id="case-large" value="large">
<label class="form-check-label fw-bold" for="case-large">Large</label>
<p class="card-text mb-0">Adds room for a tablet.</p>
</div>
</div>
</fieldset><!-- Fieldset dropped, legend destroyed with display:none, grouping left to a div -->
<div class="option-cards d-flex gap-2" role="radiogroup" aria-label="Case size">
<div class="card option-card flex-fill">
<div class="card-body">
<input type="radio" name="case-size" id="case-small" value="small" checked>
<label for="case-small">Small</label>
</div>
</div>
<div class="card option-card flex-fill">
<div class="card-body">
<input type="radio" name="case-size" id="case-large" value="large">
<label for="case-large">Large</label>
</div>
</div>
</div>
<fieldset class="d-none">
<legend>Case size</legend>
</fieldset>[/escape]Known Limitations
- Fieldset-only detection: grouping via
role="radiogroup",aria-describedbyor plain container markup is treated as ungrouped, so a valid ARIA implementation can still be reported. - Name-string heuristic: members are matched by identical trimmed
namevalues only. Two independent groups that happen to reuse a name across separate forms or sections are merged, while options whose names differ by suffix are never compared. - Hidden inputs skipped: controls with
type="hidden"oraria-hidden="true"are excluded, and an input whosenameis empty or whitespace only never joins a group, so genuinely ungrouped inputs can pass silently. - Shadow DOM and iframes: elements inside shadow roots or nested documents are outside the queried light DOM, so groups built by web components or separate frames are invisible to the scan.
- Injection timing: the audit reads the DOM at scan time. Controls appended later by infinite scroll, lazy form steps or delayed API responses are evaluated in whatever state the page happened to be in.
- One report per group: a failing name is reported once, anchored to the first element, so the issue count understates how many controls lack a group boundary and gives no signal about severity per question.
- Semantics only, not intent: it cannot tell whether the chosen grouping matches the visible question, whether the legend text is meaningful, or whether mutually exclusive radios were declared as separate name groups.
Resources
- WCAG 1.3.1 Understanding: the normative explanation of why structure must be programmatic, with the fieldset and legend technique listed as sufficient info and relationships.
- Technique H71: the worked example of grouping form controls with fieldset and legend, including the note on providing a description H71.
- MDN fieldset: browser behaviour, default styling and the constraint that fieldset and legend are the only direct children allowed <fieldset>.
- MDN radio input: the grouping semantics tied to a shared
nameand the native arrow-key single-selection behaviour radio. - HTML Living Standard: the specification text for form control grouping and legend association in the HTML form elements chapter.
Rule
- Audit: accessibility
- Standard: WCAG
- Level: A
- Success Criteria: 1.3.1
- Rule ID:
group_elements_name_attribute