fieldset ElementThe fieldset element is a block-level element declared by the XHTML 1.1 Forms Module but is not present in the
*W3C XHTML 1.1 Basic Forms Module
Elements in the Forms Module are:form | label | textarea | select | optgroup | option | button | fieldset | legend | input type="button" | input type="checkbox" | input type="file" | input type="hidden" | input type="image" | input type="password" | input type="radio" | input type="reset" | input type="submit" | input type="text"
The fieldset element is used to group related
form controls within a form. It is usually used in combination with the
legend element, which acts
as a heading for the fieldset. Fieldsets may be nested, if required.
Here is a simple fieldset example, collecting together two sets of labelled
input type="text" controls:
<form action="" method="post">
<fieldset>
<legend>About You:</legend>
<label for="name">Name</label>
<input type="text" id="name" name="name" /><br />
<label for="email">Email Address</label>
<input type="text" id="email" name="email" /><br />
</fieldset>
<fieldset>
<legend>About Your Dog:</legend>
<label for="dname">Name</label>
<input type="text" id="dname" name="dname" /><br />
<label for="breed">Breed</label>
<input type="text" id="breed" name="breed" /><br />
<label for="age">Age</label>
<input type="text" id="age" name="age" /><br />
</fieldset>
<div><input type="submit" value="Submit Details" /></div>
</form>
This renders as:
No styles have been applied to the fieldset or
legend elements above, so they
are displayed using your browser's default styles. Default behaviour is
commonly to put a border around the fieldset,
with any legend inserted
into the border (breaking it) at the top left. Of course,
CSS may be used to control
appearance in graphical user agents. Note that the
input type="submit"
element is enclosed within a div
because all children of form
elements must be block-level elements.
Note: Bear in mind that some
screen readers may read out the contents of the
legend element prior to each
label within a fieldset,
so legends should be short and make sense when read out before each and every
label within the fieldset.
A fieldset element is
also very useful for attaching (via a child
legend element)
a semantically-significant label to a set of radio buttons
(see input type="radio")
or checkboxes
(see input type="checkbox").
There are no #REQUIRED attributes on the fieldset element.
There are no specific attributes declared on the fieldset element.
fieldset element are listed below:class [ type NMTOKENS ]id [ type ID ]style [ type CDATA ], from the Style Attribute Module (deprecated)title [ type Text ]xmlns [ type URI - #FIXED 'http://www.w3.org/1999/xhtml' ]dir [ type Enumeration (ltr | rtl) ], from the Bi-directional Text Modulexml:lang [ type LanguageCode ]All attributes in the
Events Attribute Collection
are supported:onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup
fieldset element is:
( #PCDATA | legend | Flow.mix )*
See Content Model & Nesting for information about Content Model syntax and Nesting Groups.
fieldsetabbr, acronym, address, blockquote, br, cite, code, dfn, div, em, h1 - h6, kbd, p, pre, q, samp, span, strong, varadl, ol, ultablebutton, fieldset, form, input, label, legend, select, textareaimgb, big, hr, i, small, sub, sup, ttmapnoscript, scriptdel, insbdoobjectrubyfieldsetbodyblockquote, divdd, litd, thfieldset, formmapnoscriptdel, insobject