Skip to main content
Official government website

Fieldset

Groups related form controls with a shared, accessible legend.

Examples
HTML and React
Group
Form elements
On this page

Preview

Fieldset with related inputs
Open in new tab

Use a fieldset when several form controls make up one answer or need one shared question. The <legend> names the group, so screen readers announce the relationship between the controls. The React Fieldset component supplies the outer .govbb-form-group; include that wrapper explicitly when writing HTML.

Usage

When to use

  • Use a fieldset when several controls answer one question, such as an address or the parts of a date.
  • Use it for groups of radio buttons or checkboxes so the shared question is announced with every option.

When not to use

  • Do not use a fieldset around one ordinary input; use a form group with a label.
  • Do not use a fieldset only for visual layout or to divide unrelated sections of a form.

How it works

The first child of the fieldset must be a legend. Write the legend as a clear question or group name, in sentence case. Every control inside the fieldset still needs its own label; the legend does not replace those labels.

Keep the fieldset inside a .govbb-form-group so it follows the same vertical rhythm as other form controls. Nested inputs can each use their own form group to keep their labels, hints, errors and controls together.

Use the dedicated radio, checkbox or date input guidance when one of those components already matches the question.

Legend as the page heading

On a one-question-per-page form, the legend can contain the page heading. This avoids repeating the same question as both a heading and a legend.

Legend as the page heading
Open in new tab

Use only one <h1> on the page. Keep any general help text inside the legend short; put longer instructions after the legend as hint text and connect them to the fieldset with aria-describedby.

Accessibility

  • Do not remove the fieldset or legend because the visual design seems to make the grouping obvious. Screen reader users need the semantic relationship.
  • Keep the legend concise. Screen readers may announce it before every control in the group.
  • Do not add role="group" to a native fieldset unless a specific compatibility issue requires it; the fieldset already provides group semantics.
  • Connect group-level hints and errors to the fieldset with aria-describedby, using stable element IDs.