**`<fieldset>`** visually and semantically groups related controls — for example, all the fields for a 'Shipping Address' section, or a set of radio buttons that represent one logical question. Browsers render a default border around it. Setting the **`disabled`** attribute on a `<fieldset>` disables every form control nested inside it at once, which is a convenient way to disable a whole section (e.g. while a form is submitting) without disabling each field individually.
1Understanding <fieldset>
`<fieldset>` visually and semantically groups related controls — for example, all the fields for a 'Shipping Address' section, or a set of radio buttons that represent one logical question. Browsers render a default border around it. Setting the `disabled` attribute on a <fieldset> disables every form control nested inside it at once, which is a convenient way to disable a whole section (e.g. while a form is submitting) without disabling each field individually.
Setting disabled directly on a <fieldset> is a quick way to lock an entire section of a form (e.g. while an async submit request is in flight) without looping through and disabling every individual input yourself.
<fieldset>
<legend>Contact Preferences</legend>
<label><input type="checkbox" name="email_opt"> Email</label>
<label><input type="checkbox" name="sms_opt"> SMS</label>
</fieldset>2Practical Example
Here is a real-world application of <fieldset> showing how it is used in production HTML.
<!-- Disabling an entire section while submitting -->
<fieldset id="paymentSection" disabled>
<legend>Payment Details</legend>
<input type="text" name="card_number">
</fieldset>3Best Practices
Follow these guidelines when working with <fieldset>:
1. Group logically related fields (like an address, or a set of radio options) inside a <fieldset>
2. Always pair it with a <legend> describing the group
3. Use fieldset's disabled attribute to disable a whole section at once when appropriate
Tip: Setting disabled directly on a <fieldset> is a quick way to lock an entire section of a form (e.g. while an async submit request is in flight) without looping through and disabling every individual input yourself.
<fieldset>
<legend>Contact Preferences</legend>
<label><input type="checkbox" name="email_opt"> Email</label>
<label><input type="checkbox" name="sms_opt"> SMS</label>
</fieldset>