Grouping Controls
Status: This is an in-progress, unapproved draft.
Grouping related form controls makes forms more understandable for all users. Group them both visually and within the code. Use the <fieldset>
and <legend>
elements to associate related form controls.
Associating related controls
The <fieldset>
element provides a container for related form elements, and the <legend>
element acts like a heading to identify the group. In the example below there are three checkboxes that are all part of an opt-in function for receiving different types of information. The legend for this group of controls highlights the action that is common to all controls, and the fact that they are all optional.
Note: Depending on the configuration, some screen readers read out the legend either with every form element, once, or, rarely, not at all. To accommodate this consider the following:
- Make the legend as short as possible for situations in which it is read together with the label each time.
- Make the individual labels sufficiently self-explanatory for situations in which legends are not read aloud, without repeating the legend in every label.
Related WCAG2.0 resources
Success Criteria:
1.3.1 Info and Relationships: Information, structure, and relationships conveyed through presentation can be programmatically determined or are available in text. (Level A)
3.3.2 Labels or Instructions: Labels or instructions are provided when content requires user input. (Level A)
Techniques: