Recent chats
ASKGEEZ Q&A GUIDETechnology & devices

How do I group related form controls under one legend?

Quick answer

Wrap controls that belong together in a <fieldset> and use a <legend> inside it to describe the group. For example, “Notification preferences” can name related notification choices, while each choice still has its own label. This grouping-and-naming pattern appears in the cited form examples [S1][S2]. Those examples do not establish how every browser or assistive technology presents a group.

LET’S WORK THROUGH IT

The question, the details, the next step.

Question

What should I use when several form controls belong together?

Geez

Use a <fieldset> around the related controls, with a <legend> inside it that gives the group a name. This pattern can help organize controls under one topic. For instance, a form might have one group for notification preferences and another for volume settings; those are separate topics, so they should not share one group. A Google tutorial uses fieldsets for similar controls such as volume and notifications [S1]. A Microsoft form tutorial demonstrates a fieldset with the legend “Movie Information” and individual labels for fields [S2].

Follow-up question

Could you show me a grouped set of choices, including the individual labels?

Geez

Here is an illustrative example for a settings form. The specific choices are placeholders; adjust them to match what your form actually offers.

<fieldset>
  <legend>Notification preferences</legend>

  <input id="email-updates" name="updates" type="checkbox">
  <label for="email-updates">Email updates</label>

  <input id="text-updates" name="updates" type="checkbox">
  <label for="text-updates">Text updates</label>
</fieldset>

The legend names the subject of the group; each label names its own control. The cited tutorials demonstrate this general grouping-and-naming pattern [S1][S2]. They are not a comprehensive reference for every markup choice or a test of how particular browsers and assistive technologies present this example.

Follow-up question

How do I decide whether two controls belong in the same fieldset, and how long should the legend be?

Geez

Ask whether someone would naturally describe the controls as parts of one topic. “Notification preferences” can name multiple notification choices; a separate question about contact details would usually need its own group if you choose to group it. Keep the legend brief but specific enough to distinguish the group from nearby groups. Avoid a broad label such as “Options” when the form contains several kinds of options. The tutorials illustrate group names such as “Movie Information,” but they do not prescribe an ideal legend length [S2]. Treat concise wording as a writing choice, not a length rule established by those examples.

Follow-up question

What should I check before I finish the form?

Geez

Review the form from the group level down to each control. Check that each fieldset contains controls with a shared topic, that its legend names that topic, and that each control still has a clear individual label. Then read the legends in order: if two adjacent groups sound interchangeable, make their names more distinct. The markup pattern is a starting point, not proof that the form works well in every browser or assistive technology; the cited tutorials do not establish that. If your project has accessibility testing requirements, follow its applicable review process rather than assuming the example alone settles them.

A practical checklist

  • Group controls only when they share a clear topic.

  • Use a concise, specific legend to name each group.

  • Give each individual control its own clear label.

  • Distinguish nearby groups with names that are not interchangeable.

  • Follow the testing process appropriate to your project.

A few more useful answers

Can the legend replace the labels for the individual controls?

No. Use the legend to name the group and keep a clear label for each control, as illustrated by the grouped-fields example [S2].

Do the examples prove how every screen reader will announce a fieldset?

No. The supplied tutorials demonstrate markup patterns, but do not establish presentation or announcement behavior across browsers and assistive technologies [S1][S2].

Sources

References used for this guide.

  1. [S1] Build user-adaptive interfaces with preference media queries
    codelabs.developers.google.com · Checked
  2. [S2] Introducing ASP.NET Web Pages: Entering Database Data by Using Forms
    learn.microsoft.com · Checked

YOUR QUESTION. YOUR DETAILS.

Let’s work through your situation.

Get a tailored answer or help with your next task. Starts at $1, with a quote before you pay.

Ask your own question
← Back to Geez at Work