< html‎ | elements
Jump to: navigation, search


This article is In Progress.


The fieldset element is used to group related elements in a form.

Overview Table

DOM Interface HTMLFieldSetElement

The fieldset element represents a set of form controls. Optionally grouped under a common name with an additional legend element.

HTML5 adds the following attributes which are fully optional.

Attributes (HTML 5)

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, which is submitted with the form data. The label for the field set is given by the first legend element that is a child of this field set.


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.

Nesting fieldsets

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

Related specifications

Specification Status Related Changes
HTML5 W3C Candidate Recommendation
HTML 4.01 Specification W3C Recommendation New attributes: disabled, form, name



Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support ? ? ? ? ?


Feature Android BlackBerry Chrome for mobile Firefox Mobile (Gecko) IE Mobile Opera Mobile Opera Mini Safari Mobile
Basic support ? ? ? ? ? ? ? ?

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 cc-by-sa-small-wpd.svg: Article

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