HTML <legend> tag
The <legend> tag is used to set a title for a fieldset. A fieldset is used to group together a set of elements that you choose by drawing a box around them. This will present those elements in a more easily readable way by adding emphasis.
Attributes
| Attribute | Possible values | Description |
|---|---|---|
| align | left, right, top, bottom | Deprecated. Sets the alignment of the fieldsets title |
Standard attributes
accesskey, class, dir, id, lang, style, title, xml:lang
For more information on standard attributes, check out our HTML standard attributes reference page.
Event attributes
onclick, ondblclick, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onkeydown, onkeypress, onkeyup
For more information on event attributes, check out our HTML event attributes reference page.
Example
Tips & notes
Use the <fieldset> tag together with the <legend> tag.
While the <fieldset> + <legend> tags combination is usually used with forms, you don't necessarily have to use it with a form. A good example of using the <fieldset> tag with something else besides a form can be found on our Web development jobs tutorial. Scroll down a little on this page until you see the green box. This is the <fieldset> + <legend> tags at work without a form.