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.
Syntax:
<legend> text..</legend>
Example
<fieldset> <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> </fieldset>
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
HTML4 | XHTML | 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
Related Tags
<fieldset>, <input>, <form> tags.