Rule
Grouped field labels
Radio and checkbox groups should be grouped with a label.
- Rule
fieldset-legend- Type
- Best practice, not a WCAG requirement. It runs when Best practices is switched on.
- Severity
- Moderate
What it checks
The rule groups radio buttons and checkboxes by type and name within the same form. A group of two or more fails unless every control in it sits inside one <fieldset>, role="group" or role="radiogroup" that is named, by a <legend>, aria-labelledby or aria-label. One finding is reported per group.
Each option's own label says what the option is, not what question it answers. A group label lets a screen reader announce the question, such as "Delivery speed", as focus enters the group.
Example
Fails
<p>Delivery speed</p>
<input type="radio" id="standard" name="speed" value="standard">
<label for="standard">Standard</label>
<input type="radio" id="express" name="speed" value="express">
<label for="express">Express</label>
Passes
<fieldset>
<legend>Delivery speed</legend>
<input type="radio" id="standard" name="speed" value="standard">
<label for="standard">Standard</label>
<input type="radio" id="express" name="speed" value="express">
<label for="express">Express</label>
</fieldset>
The engine is tested against both examples.
How to fix it
Wrap the group in a <fieldset> whose first child is a <legend> that asks the question.
Check your own pages
This rule runs in every pour audit: the browser extension, the bookmarklet, the command line and the editor. Get pour, free.