Home HTML Tags <fieldset> HTML <fieldset> Tag Definition
Definition and Usage The <fieldset> element groups related form controls and their <label> s. A nested <legend> provides the caption for that group.
Use it inside a <form> for shipping details, payment choices, preferences, and other related fields. The disabled attribute can turn off every control in the group at once.
Baseline · Widely available. Not deprecated and not experimental. Stable across modern browsers since about July 2015.
Caption = first legend. The first <legend> nested in the fieldset is the group title. Put it first when you can.
Syntax
HTML Syntax <fieldset> <legend>…</legend> …controls… </fieldset>
Both start and end tags are required. Content is an optional <legend>, then flow content (inputs, labels, paragraphs, and so on).
Reference
Attributes The attributes you will use most often on <fieldset>:
Attribute Description Try it disabledDisables descendant form controls (not editable, not submitted). Controls inside legend stay enabled Try itnameName associated with the group (does not replace name on inputs) Try itformAssociates the fieldset with a <form> by id. Prefer nesting inside the form; see edge cases Advanced
Try it
Live Preview Toggle disabled on a real <fieldset> and try the controls.
Code
HTML Examples Short, copy-ready snippets. Use Try It Yourself for a live editor.
1. Basic group 2. With checkbox 3. Disabled 4. Multiple groups Example 1 — Basic Group with Legend Wrap related radios in a fieldset and caption them with legend.
<form>
<fieldset>
<legend>Favorite fruit</legend>
<input type="radio" id="apple" name="fruit" value="apple">
<label for="apple">Apple</label><br>
<input type="radio" id="mango" name="fruit" value="mango">
<label for="mango">Mango</label>
</fieldset>
</form> How It Works Open <fieldset> around the related controls.Add <legend> first as the group caption.Place inputs and labels inside the fieldset.Close the tags so the browser draws the grouped box.Example 2 — Agreement Checkbox Group A short fieldset works well for a single related decision.
<form>
<fieldset>
<legend>Do you agree?</legend>
<input type="checkbox" id="agree" name="agree" value="yes">
<label for="agree">I agree to the terms</label>
</fieldset>
</form> How It Works Caption the decision with <legend>.Connect label and input with matching for / id.Keep only related controls in that fieldset.Let the legend name the group for screen reader users.Example 3 — Disable a Whole Group One disabled attribute turns off descendant controls.
<form>
<fieldset disabled>
<legend>Login (disabled)</legend>
<label for="user">User</label>
<input id="user" name="user" type="text" value="chris">
<label for="pwd">Password</label>
<input id="pwd" name="pwd" type="password" value="secret">
</fieldset>
</form> How It Works Add disabled on the <fieldset>.Descendant inputs become disabled — no edit, no submit, usually grayed out.Exception: controls inside the <legend> are not disabled by this attribute.Remove disabled (or toggle it with script) to re-enable the group.Example 4 — Multiple Named Groups Split a form into clear sections with separate fieldsets.
<form>
<fieldset name="shipping">
<legend>Shipping</legend>
<label for="city">City</label>
<input id="city" name="city" type="text">
</fieldset>
<fieldset name="billing">
<legend>Billing</legend>
<label for="card">Card last 4</label>
<input id="card" name="card" type="text" maxlength="4">
</fieldset>
</form> How It Works Create one fieldset per topic (Shipping, Billing).Give each a clear legend .Optional name on the fieldset names the group in the DOM — inputs still need their own name.Keep each group focused so users and assistive tech can scan the form. Edge Cases & Pitfalls Most fieldset bugs come from missing legends or misunderstanding disabled / form.
a11y Always add a legend Without <legend> , the group has a weak accessible name. Put a clear caption first.
disabled Legend controls stay active disabled on fieldset does not disable form controls placed inside the legend. Keep interactive controls out of the legend unless that is intentional.
form attr form on fieldset is easy to misuseAssociating the fieldset with a form by id does not automatically associate every control. Prefer nesting, or set form on the controls themselves.
labels Still label each control A legend names the group. Each input still needs its own <label> .
styling Default border is normal Browsers draw a groove border and padding. Restyle freely with CSS; legend sits on the start border by default.
Compatibility
Browser Support The <fieldset> element is core HTML in every browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
<fieldset> Widely available since about July 2015 (and long before as a form grouping element). Chrome, Firefox, Safari, Edge, and Opera all support it fully.
98% Global support (approx.)
Google Chrome All
Full support
Mozilla Firefox All
Full support
Apple Safari All
Full support
Microsoft Edge All
Full support
Opera All
Full support
Samsung Internet All
Full support
Internet Explorer All
Supported <fieldset> Widely supported
Bottom line: Safe to use everywhere for grouping form controls. Pair with legend, and prefer nesting inside form.
Remember
Key Takeaways Role: <fieldset> groups related controls; <legend> names the group.
disabled: turns off descendant controls in one step (except those in the legend).
Structure: nest inside <form> when you can; still label every control.
form attribute: advanced and easy to misuse — associate controls carefully.
One line: a good fieldset has a clear legend and only related controls inside.
UA style
Default CSS Settings Typical user-agent styling (exact values can vary by browser):
fieldset {
display: block;
margin-inline: 2px;
border-width: 2px;
border-style: groove;
border-color: ThreeDFace;
padding-block: 0.35em 0.625em;
padding-inline: 0.75em;
min-inline-size: min-content;
} You may restyle freely. If you set display: flex or grid on the fieldset, an anonymous content box becomes the flex/grid container for the children.
Frequently Asked Questions What is the HTML fieldset tag used for? The fieldset element groups related form controls and their labels. A nested legend element provides the caption for that group.
Is legend required inside fieldset? It is strongly recommended. The first legend inside the fieldset is the group caption and is important for accessibility. Put legend first when you can.
What does the disabled attribute do on fieldset? It disables descendant form controls in one step. They are not editable, do not submit, and usually look grayed out. Controls inside the legend are not disabled by that attribute.
Can a fieldset sit outside its form? You can set form="form-id" on fieldset, but associating the controls themselves still needs care. Prefer nesting fieldset inside the form, or put form on each control you want linked.
Does fieldset have its own name? Yes. The name attribute names the group. It does not replace name on individual inputs.
What is the accessibility role of fieldset? The implicit ARIA role is group. With a legend, assistive tech can announce the group name for the controls inside.
About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
12 people found this page helpful
Helpful Share Copy link Suggestion