Html5 legend tag

In the html 5 <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 5 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 5 for <legend> element suppose if you need to use css instead.

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