jim.shamlin.com

Field Sets

The HTML Field set, which a child of a form (and a parent of some of its elements) is not an input element, but a way to group certain elements together, such as an "address" field set containing a street address, apartment number, city, state, and ZIP code. The user must access (and the developer may manipulate) the individual elements.


Basics

Bare-bones code for a field set is:

<FIELDSET>
     <LEGEND>Address</LEGEND>
     Line 1: <INPUT TYPE="text" SIZE="30"><BR>
     Line 2: <INPUT TYPE="text" SIZE="30"><BR>
     City: <INPUT TYPE="text" SIZE="30"><BR>
     State: <INPUT TYPE="text" SIZE="30"><BR>
     ZIP Code: <INPUT TYPE="text" SIZE="10">
 </FIELDSET>

In most browsers, it will render a border around the fields with the LEGEND (which is optional) appearing above it, or set into the top of the border.


Usage

A field set is used to provide the user with a visual indication that a number of input fields are components or a larger set of data. A few sources stress that it should not be used arbitrarily - but its very nature seems arbitrary.


Processing

No information about a field set is passed to the server for processing.


HTML Attributes

The FIELDSET and LEGEND tags do not have the NAME or VALUE elements of form elements.

An ALIGN attribute is defined for the LABEL - left, right, or center - but it is already deprecated in favor of using CSS for formatting.


JavaScript

The FIELDSET and LEGEND tags do not have any unique properties, methods, or event handlers. We browsers tend to treat them like any other block-level HTML entity.


Misc Notes

I haven't needed to use a field set, and since implementation varies, I tend to avoid it in lieu of using a DIV to enclose form fields. It seems a bit odd to me, with no clear advantages, so I expect it will eventually be deprecated.