html tutorial - <legend> - Legend Tag in HTML - html5 - html code - html form

legend tag in html

Learn html - html tutorial - legend tag in html - html examples - html programs

  • The <legend> tag is used to define as a caption for the <fieldset> tag.
  • Both the <legend> tag can be used in conjunction with <fieldset>, <details> and <figure> tag.
  • The <legend> tag supports the Global Attributes and Event Attribute.

Syntax for <legend> tag:


Differences between HTML 4.01 and HTML 5 for <legend> tag:

HTML 4.0.1

  • HTML4 supports align attribute.


  • HTML5 does not supports align attribute.

Sample Coding for <legend> tag:

Tryit<!DOCTYPE html>
<html >
                <legend>Wikitechy Database</legend>
                 Name:<input type="text" size="30"><br><br>
                 DOB:<input type="text" size="30"><br><br>
                 Designation:<input type="text" size="10">

Code Explanation for <legend> tag:

<legend> Tag Code Explanation

  1. The <legend> tag is used to define a caption for the <fieldset> tag within the <form> tag to form the design for Personal details.

Output for <legend> tag:

<legend> Tag Output

  1. Output displays the Wikitechy Database form details with the caption.

Attribute of <legend> tag:

Attribute Value HTML4 HTML5 Description
align top
Yes No It is used to specify the alignment of the captions.

Browser Support for <legend> tag in HTML:

Yes Yes Yes Yes Yes

Related Searches to legend tag in html