HTML <legend>Tag
Examples
Group related elements in a form:
<form>
<fieldset>
<legend>Personalia:</legend>
Name: <input type="text" size="30"><br>
Email: <input type="text" size="30"><br>
Date of birth: <input type="text" size="10">
</fieldset>
</form>
<fieldset>
<legend>Personalia:</legend>
Name: <input type="text" size="30"><br>
Email: <input type="text" size="30"><br>
Date of birth: <input type="text" size="10">
</fieldset>
</form>
Try it Yourself »
Browser Support
![]()
Currently, most browsers support the <legend> tag.
Tag Definition and Usage Instructions
The <legend> element defines<fieldset>a caption for the <fieldset> element.
Differences Between HTML 4.01 and HTML5
In HTML 4.01, the "align" attribute has been deprecated, and HTML5 does not support this attribute. It is not recommended for use. Please use CSS to set the alignment of the <legend> element.
Attributes
| Attribute | Value | Description |
|---|---|---|
| align | top bottom left right |
Not supported in HTML5. Deprecated in HTML 4.01. Not recommended for use.Use styles instead. Defines the alignment of the caption in fieldset. |
Global Attributes
The <legend> tag supports global attributes. View the complete attribute table.HTML Global Attributes。
Event Attributes
The <legend> tag supports allHTML Event Attributes。
Other Extensions