< html‎ | elements
Jump to: navigation, search


This article is Ready to Use.

W3C Candidate Recommendation


The fieldset element is used to group related fields within a form.

Overview Table

DOM Interface HTMLFieldSetElement

The fieldset element represents a set of form controls. Optionally given a name with a child legend element.


NOTE: Those attributes are considered valid since HTML5

If this Boolean attribute is set, the form controls that are its descendants, except descendants of its first optional legend element, are disabled, i.e., not editable. They won't receive any browsing events, like mouse clicks or focus-related ones. Often browsers display such controls as gray.
This attribute has the value of the id attribute of the form element its related to. Its default value is the id of the nearest <form> element it is a descendant of.
The name associated with the group. This is for use in the form.elements API.


View live exampleSimple form with fieldset, legend, and label elements.


<form action="" method="post">
    <label for="radio">Click me</label>
    <input type="radio" name="radio" id="radio">

View live exampleThe following snippet shows a fieldset with a checkbox in the legend that controls whether or not the fieldset is enabled.


  <fieldset name="clubfields" disabled>
      <label for="club">Use Club Card</label>
      <input type="checkbox" id="club" name="club" onchange="form.clubfields.disabled = !checked">
     <label for="clubname">Name on card:</label>
     <input name="clubname" type="text">
     <label for="clubnum">Card number:</label>
     <input name="clubnum" type="number">
     <label for="clubnum">Expiry date:</label>
     <input name="clubexp" type="date">


View live exampleExample with nested fieldset elements.


<form action="">
  <fieldset name="clubfields" disabled>
      <label for="club">Use Club Card</label>
      <input type="checkbox" name="club" id="club" onchange="form.clubfields.disabled = !checked">
     <label for="">Name on card:</label>
     <input name="clubname">
   <fieldset name="numfields">
       <label for="clubtype">My card has numbers on it</label>
       <input type="radio" checked name="clubtype" id="clubtype" onchange="form.numfields.disabled = !checked">
       <label for="clubnum">Card number:</label>
       <input name="clubnum" id="clubnum" type="text">
   <fieldset name="letfields" disabled>
       <label>My card has letters on it</label>
       <input type="radio" name="clubtype" id="clubtype" onchange="form.letfields.disabled = !checked">
       <label for="clublet">Card code:</label>
       <input name="clublet" id="clublet">



Fieldsets are not required but useful for grouping elements in a form to enhance the visual flow and usability of complex forms. optionally you can use a legend element to give your fieldset element a caption.


Default layout

Typically, the browser draws a box around the containing elements of every fieldset. This border can be disabled via CSS border: none; The border contains the legend by default. See legend for details.

The "Rendering" section of the WHATWG HTML specification suggests min-width: min-content as part of the default style for fieldset, and many browsers implement such styling (or something that approximates it); almost no other element shares this default style. See also StackOverflow, Mozilla bug #504622, and WebKit bug #123507.

Nesting fieldsets

It’s also possible and in certain use cases pretty useful to nest fieldsets.


Not all form control descendants of a disabled fieldset are properly disabled in IE11; see IE bug 817488: input[type="file"] not disabled inside disabled fieldset and IE bug 962368: Can still edit input[type="text"] within fieldset[disabled].

Related specifications

Specification Status Related Changes
HTML 5.1 W3C Working Draft
HTML 5 W3C Recommendation
HTML 4.01 W3C Recommendation

See also

Related articles


  • fieldset

… further results

Other articles

External resources


This article contains content originally from external sources.

Portions of this content come from the Mozilla Developer Network
Error creating thumbnail: File missing
: Article

Portions of this content come from the Microsoft Developer Network: [Windows Internet Explorer API reference Article]