Forms and validation: Grouped choices
fieldset and legend give a related set of form controls a shared accessible name.
Current edit
Understand the pattern
fieldset and legend give a related set of form controls a shared accessible name.
fieldset and legend give a related set of form controls a shared accessible name.
Misconceptions to reject
- A visual appearance alone guarantees the intended HTML meaning.
- Replacing semantic elements with generic divs automatically improves accessibility.
The preview is a sanitized subset, not a full browser compatibility test.
Worked example and expected result
<fieldset><legend>Choose a track</legend><label><input type="radio" name="track" value="unix">UNIX</label><label><input type="radio" name="track" value="web">Web</label></fieldset>fieldset and legend give a related set of form controls a shared accessible name.
Explain it
Apply it elsewhere
Keep the momentum.
Complete the lab, then explain and apply the pattern.
Next: Forms and validation: Confirmation statesTry an incident drillAnonymous lesson and mastery progress lasts for this session. Sign in to keep synced lesson XP between sessions; mastery stays device-local. No speed bonus, lost lives, or hint penalties.
Keep learning
- 01Forms and validation: Input descriptionsA placeholder is not a replacement for a visible label or persistent help text.Practice
- 02Forms and validation: Confirmation statesA status region can announce a completed action while leaving focus on the current control.Practice
- 03Forms and validation: Validation checkpointAn accessible input combines a label, the appropriate type, a visible requirement, and connected help.Practice