Skip to content

<legend> - The Legend Element

Form Control HTML 4.0

The legend element provides a caption or title for its parent <fieldset> element. It helps users understand what a group of form controls represents and is essential for accessibility.

Result
<fieldset>
<legend>Group Title</legend>
<!-- Form controls -->
</fieldset>

The legend must be the first child of a <fieldset> element.

The <legend> element has no specific attributes beyond the global attributes like id, class, and style.

Result
Result
Result
Result
Result
Result
Result
Result
Result
Result
Result
Result
Result

Screen readers announce the legend before each form control in the fieldset:

Result
<legend>Shipping Method</legend>
<legend>Payment Information</legend>
<legend>Contact Preferences</legend>

Screen readers repeat the legend for each control, so keep it short and clear.

Result
<fieldset>
<legend>Newsletter Subscription</legend>
<label>
<input type="checkbox" name="subscribe">
Subscribe to newsletter
</label>
</fieldset>
<legend>T-Shirt Size</legend>
<legend>Dietary Restrictions</legend>
<legend>Payment Method</legend>
<fieldset>
<legend>Title</legend>
<label><input type="radio" name="x">Option</label>
</fieldset>
BrowserVersionNotes
Chrome1+Full support
Firefox1+Full support
Safari1+Full support
Edge12+Full support
IE4+Full support

The <legend> element has been supported since early browser versions.