| Depr. | Empty | Version |
|---|---|---|
| No | No | HTML 4 |
| IE5.5+ | FF1+ | SA1.3+ | OP9.2+ | CH2+ |
|---|---|---|---|---|
| Full | Full | Full | Full | Full |
Syntax
Description
The
fieldset is a useful tool for organizing and grouping
related items within a form, and has been used for a
long time in desktop applications. When it’s combined with the legend (which is contained inside the
fieldset, and is a required element if you use the
fieldset), it has the effect of creating a box around
the grouped items and showing a description to the right of each item, as
shown in Figure 1.
It’s also possible to nest fieldsets as a means to subgroup items, as shown in Figure 2.
Example
This
fieldset element is used to group three related XFN
attributes (see the Microformats section regarding
XFN):
<form>
<fieldset>
<legend>Friendship</legend>
<input type="radio" name="radFriendship" value="Not_Applicable"
id="radFriendNot_Applicable"/>
<label for="radFriendNot_Applicable">Not_Applicable</label>
<input type="radio" name="radFriendship" value="acquaintance"
id="radFriendaquaintence"/>
<label for="radFriendaquaintence">acquaintance</label>
<input type="radio" name="radFriendship" value="friend"
id="radFriendfriend"/>
<label for="radFriendfriend">friend</label>
</fieldset>
⋮
</form>
Use This For …
The
fieldset attribute is used to logically group data
items that share some characteristics. For example, you may wrap a
fieldset around personal details, and another around
work details, when capturing information about a visitor in an application
form.
Compatibility
| Internet Explorer | Firefox | Safari | Opera | Chrome | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 8.0 | 1.0 | 1.5 | 2.0 | 3.0 | 3.5 | 1.3 | 2.0 | 3.1 | 4.0 | 9.2 | 9.5 | 10.0 | 2.0 |
| Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | Full |
It causes no compatibility issues, and has excellent support across all tested browsers.
User-contributed notes
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.