Next / Previous / Contents / TCC Help System / NM Tech homepage

14.8. The fieldset element: Adding structure to a form

If your form is large or complex, you may want to divide it up into multiple sections, perhaps also providing a descriptive label on each section. To do this, use a sequence of fieldset elements inside the form element. Here is the content model:

element fieldset
{ Common.attrib,
  legend,
  Flow.model
}
Common.attrib

This element can carry any of the attributes described in Section 15.3, “The common attributes: Common.attrib.

legend

The legend element contains the title for this field set. See below for its content model.

Flow.model

Inside the fieldset element you can use any combination of text, inline elements, and block elements.

Here is the content model for the legend element that titles each fieldset element:

element legend
{ Common.attrib,
  Inline.model
}
Common.attrib

The usual attributes from Section 15.3, “The common attributes: Common.attrib.

Inline.model

The legend may consist of any mixture of text and inline elements; see Section 10, “Inline content: Inline.model.

Here's an example of the use of fieldset.

  <form action="handler.cgi" method="post">
    <fieldset>
      <legend>Attitudes about fish</legend>
      ...form elements...
    </fieldset>
    <fieldset>
      <legend>Attitudes about birds</legend>
      ...form elements...
    </fieldset>
  </form>