HTML <legend> tag

Updated: 11/13/2018 by Computer Hope
HTML legend tag

When 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, and related attributes and browser compatibility.


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

Example of <legend> code

<legend>Personal Information:</legend>
Name: <input type="text"><br>
Address: <input type="text"><br>
Email: <input type="text"><br>
Phone: <input type="text">

Example result

Personal Information: Name:

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, and 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.


Edge Internet Explorer Firefox Safari Opera Chrome
All versions 6.0+ 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