This is an archived story. The content, links and information may have changed since the publication date.

All Articles

Fieldsets and legends in HTML

Author: Diana Pounds

Fieldsets are a good way to group form items that naturally go together. Likely candidates for grouping are personal info (name, address, phone, etc.), credit card information or checklists, like the example below.

Choose your favorite campus icon 
 
 

Here's the HTML for the fieldset above.

<form method="post">
<fieldset>
<legend>Choose your favorite campus icon</legend>
 
<input id="campanile" name="icon" type="checkbox" />
<label for="campanile">Campanile</label>
 
<input id="laverne" name="icon" type="checkbox" />
<label for="laverne">Lake LaVerne</label>
 
<input id="seasons" name="icon" type="checkbox"/>
<label for="seasons">Four Seasons fountain</label>
 
</fieldset>
</form>