Encodera

Thanks for reading!

Donate to the site — we work hard for you.

HTML & CSS reference

<fieldset>, <legend>

A group of related form fields with a `<legend>` title.

Syntax

<fieldset><legend>Title</legend>…</fieldset>

Attributes

ParameterTypeDescription
disabled—Optional. Disable all fields of the group at once.

Examples

A group of radio buttons:

<fieldset>
  <legend>Delivery</legend>
  <label><input type="radio" name="delivery" checked> Courier</label>
  <label><input type="radio" name="delivery"> Pickup</label>
</fieldset>

A disabled group:

<fieldset disabled>
  <legend>Gift wrapping (coming soon)</legend>
  <input placeholder="Message on the card">
</fieldset>

Notes

<legend> must be the first element inside <fieldset>. Screen readers announce it before each field of the group — especially important for radio buttons. The default border and padding can be removed in CSS.

See also

  • <form> — A form: collects data from its fields and sends it to the server.
  • <label> — A label for a form field.
  • <input type="checkbox"> — A checkbox is an independent yes/no choice; a radio button picks one option from a group.

Related recipes

In the tutorial

  • Labels and field groups — The label tag and linking a label to a field with for and id, nested labels, grouping fields with fieldset and legend.

Thanks for reading!

Donate to the site — we work hard for you.