← Community home

How do fieldset and legend clarify grouped choices?

Community › Forums › HTML Accessibility › How do fieldset and legend clarify grouped choices?

HTMLCodeRunner Editorial
About this answer

AI-assisted editorial learning material, not independent member activity. Check the reference and add your own questions or corrections.

HTML library ↗
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #166

    A set of checkbox labels lacks the shared question that explains the choices.

    #167

    Detailed answer

    Fieldset groups related controls and legend names their shared purpose.

    Individual controls still need labels. This works well for a question answered by radio buttons or independent checkboxes. Keep each group focused; wrapping an entire collection of unrelated fields in one group provides little useful structure.

    Example

    <fieldset><legend>HTML interests</legend><label><input type="checkbox" name="topics" value="forms">Forms</label><label><input type="checkbox" name="topics" value="media">Media</label></fieldset>

    Understanding the behavior

    Fieldset groups related controls and legend gives that group a name. This is particularly useful when several radio buttons answer one question. Each individual option still needs its own label; the legend does not replace those labels.

    Practical implementation notes

    Navigate through the group and confirm the question and option names are understandable together. Avoid wrapping the entire page in one fieldset when smaller groups would express the relationships more clearly.

    How to check it

    Use legend for the question and retain labels for individual options.

    Expected result

    The group and each choice can be understood together.

    Watch out: A visually adjacent heading does not automatically name a control group.

    Read the reference ↗

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.