15 / 17

What are fieldsets and legends in forms?

Using Fieldsets and Legends in HTML Forms

In HTML forms, the <fieldset> element is used to group related inputs together, and the <legend> element provides a caption or title for that group. This helps improve form organization and accessibility by making the structure clearer to both users and screen readers.

Key Points About Fieldsets and Legends
  1. 1

    <fieldset> creates a visual box around grouped form controls.

  2. 2

    <legend> provides a title or description for the <fieldset>.

  3. 3

    Improves accessibility by giving context to grouped fields.

  4. 4

    Commonly used for grouping sections like personal info, login details, or preferences.

Example of Fieldset and Legend Usage