HTML <legend> tag

Updated: 10/11/2017 by Computer Hope

HTML legend tagWhen writing in HTML, the <legend> tag is used to designate a caption for the <fieldset> element. The following sections contain information about this tag, including an example of it in use, as well as related attributes and browser compatibility.

Note: The <legend> tag belongs to a group of tags called form elements.

Example 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

Personal Information: Name:
Address:
Email:
Phone:

Deprecated attributes

Within an HTML tag, an attribute dictates certain aspects of an HTML element. Attributes are made up of a name and value pair; all tags support standard attributes. The following table shows all of the deprecated unique HTML attributes for the <legend> tag, as well as a description of each. While these attributes may work with the some versions of HTML, they will eventually be phased out. You should use CSS to adjust the dimensions of this element.

Attribute Description
align Designates the alignment of the caption

Compatibility

Internet Explorer Firefox Safari Opera Chrome
All versions All versions All version All versions All versions

Additional form elements

Browser, Caption, Compatibility, HTML form tag, HTML input tag, HTML label tag, URL, Web design terms