Html Legend Tag

In the html <legend> tag is used to caption for group of element and it is a parent element. Also you can use inside of <figure>,<fieldset> and <details> elements in the html but html 4 use to <legend > tag for the <fieldset> only.

If you use <legend> tag, user can easily understand html form or element. In the align attribute only support in html for <legend> element suppose if you need to use css instead.

Html <legend> tag optional attributes is align and standard attributes are accesskey, class ,dir ,id ,lang ,style ,title and xml:lang and event attributes are onclick, ondblclick ,onmousedown ,onmousemove ,onmouseout ,onmouseover ,onmouseup ,onkeydown ,onkeypress and onkeyup.

Syntax:

<legend> ... </legend>

Example Code



<fieldset>
<legend> Register Form </legend>
  User Name : <input type="text" />
  Password : <input type="password" />
  Address : <textarea> </textarea>
  Phone No : <input type="text" />
  <input type="submit" value="submit" />
</fieldset>

Out Put:

 Registration Form   User Name :  
Password :   
Address :     
Phone No :   

In the above example has been added <fieldset> and <legend> tag for Registration Form.





Content