The Web Design Group

legend - Fieldset Caption

Syntax <legend>...</legend>
Attribute Specifications
  • accesskey=Character (shortcut key)
  • align=[ "top" | "bottom" | "left" | "right" ] (alignment relative to fieldset)
  • common attributes
Contents Inline elements
Contained in fieldset

The legend element defines a caption for form controls grouped by the fieldset element. The legend element must be at the start of a fieldset, before any other elements.

While the legend element is not widely supported by current browsers, it can still be used safely if a block-level element immediately follows the legend. Combined with careful use of fieldset, this will cause non-supporting browsers to render the caption as its own paragraph. Elements such as strong, b, and big could also be used to help express the meaning of legend to non-supporting browsers.

An example follows:

  <legend accesskey="c">Credit Card Information</legend>
    <label accesskey="v">
      <input type="radio" name="card" value="Visa" /> Visa
    <label accesskey="m">
      <input type="radio" name="card" value="MC" /> Mastercard
    <br />
    <label accesskey="n">
      Number: <input type="text" name="number" />
    <br />
    <label accesskey=e>
      Expiry: <input type="text" name="expiry" />

legend's accesskey attribute, used throughout the preceding example, specifies a single Unicode character as a shortcut key for giving focus to the legend, allowing the user to quickly jump to a group of form controls. Entities (e.g. &eacute;) may be used as the accesskey value.

The deprecated align attribute of legend suggests where the caption should be positioned relative to the fieldset on visual browsers. Possible values are top, bottom, left, and right. While align is deprecated, no alternative currently exists in Cascading Style Sheets.

More Information