HTML <legend> tag
Updated: 09/12/2023 by Computer Hope
When writing in HTML (hypertext markup language), the <legend> tag designates a caption for the <fieldset> element. The following sections contain information about this tag, including an example of it in use, and related attributes and browser compatibility.
Note
The <legend> tag belongs to a group of tags called form elements.
Example of <legend> code
<form>
<fieldset>
<legend>Personal Information:</legend>
Name: <input type="text"><br>
Address: <input type="text"><br>
Email: <input type="text"><br>
Phone: <input type="text">
</fieldset>
</form>
Example result
Deprecated attributes
All HTML tags support standard attributes that define the settings of an HTML element. In addition to the standard settings, the <legend> tag had the following unique attributes that are now deprecated.
Attribute | Description |
---|---|
align | Designates the alignment of the caption. |
Compatibility
Edge | Internet Explorer | Firefox | Safari | Opera | Chrome |
---|---|---|---|---|---|
All versions | 6.0+ | All versions | All version | All versions | All versions |
Additional form elements
- <button>
- <datalist>
- <fieldset>
- <input>
- <keygen>
- <label>
- <optgroup>
- <option>
- <output>
- <select>
- <textarea>
Browser, Caption, Compatibility, Container tag, HTML form tag, HTML input tag, HTML label tag, URL, Web design terms