<legend> tag

HTML <legend> tag

The <legend> tag describes caption (text label) for a parent element.

Most of the times, it is coded inside the <fieldset>  tag.

You can add labels for input form controls like text, button, Textarea, email etc.

<legend> text..</legend>


  <legend>Employee Details:</legend>
  Name:<br><input type="text" name="Name" value=""><br>
  Email Id:<br><input type="text" name="Email Id" value=""><br>
  Employee Id:<br><input type="text" name="Employee Id" value=""><br>
  Phone.No:<br><input type="text" name="Phone.No" value=""><br><br>
  <button type="button" onclick="document.write(‘Form submitted’)">Submit</button>

Default CSS Values

display: block;
padding-left: 2px;
padding-right: 2px;
border: none;

How Browser will display

BLOCK Level.

Difference between HTML4.01, XHTML and HTML5

NA NA align attribute is deprecated in HTML5

Attributes used with <legend> tag

Attribute Description
align To align the caption to top, right, bottom or left.
(HTML5 does not support this attribute when it is used with the <legend> tag).

Global Attributes

The <legend> tag supports Global attributes.

Event Attributes

The <legend> tag supports Event attributes.

Supporting Browsers

supporting-browsers for tags

Related Tags

<fieldset>, <input>, <form> tags.

Tutorials for all brains!