liveBook · Manning

Fieldset element

As explained in Architecting Accessibility

The HTML fieldset element groups related form controls.

Grouping related controls into meaningful sections helps people understand a form and reduces its perceived workload. Use `<fieldset>` with `<legend>` to make the relationship clear visually and programmatically; CSS borders alone do not convey it to assistive technology. section 6.1.4

<fieldset> #A
  <legend>Dog size</legend> #B
  <div>
    <input type="radio" name="size" id="small" value="s" checked> #C
    <label for="small">Small</label>
  </div>
  <div>
    <input type="radio" name="size" id="medium" value="m"> #C
    <label for="medium">Medium</label>
  </div>
  <div>
    <input type="radio" name="size" id="large" value="l"> #C
    <label for="large">Large</label>
  </div>
</fieldset>

A radio-button group titled “Dog size” shows `<fieldset>` and `<legend>` around individually labeled choices. section 6.1.4

Use grouping when controls belong together, especially for:

  • Related radio buttons, checkboxes, or fields split into components such as month, day, and year. section 6.1.4
  • Large forms divided into meaningful sections, such as owner, dog, and complaint details. section 6.1.10

A screen reader can announce a control’s label alongside its group legend, providing context such as “Name – Billing Details.” Native radio groups also provide expected keyboard behavior; a custom group requires implementing and communicating its behavior, role, name, and state. section 6.1.4 section 6.1.3

How Architecting Accessibility covers it

How deep it goes
Explains legends, screen-reader context, and native radio-button keyboard behavior, but does not detail custom-group implementation.
Examples
Demonstrates a “Dog size” radio group and form sections for owner, dog, and complaint details.
What you can do after
Build accessible form groups using `<fieldset>` and `<legend>` to label related controls and provide context.
How it connects
Connects fieldsets with legends, labels, radio buttons, checkboxes, screen readers, and keyboard navigation.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Architecting Accessibility. The section links point to the parts of the book it draws on.