HTML legend Tag

The HTML <legend> tag is used to define a title or caption for <fieldset>. The <legend> element must be the first child of the <fieldset> element. The legend elements are the parent element.

Syntax

<legend>text...<legend>

Example

<!DOCTYPE html>
<html>
   <head>
      <title>HTML legend Tag Example</title>
   </head>
   <body>
      <form>
         <fieldset>
            <legend>Login</legend>
            Username: <input type="text"><br/>
            Password: <input type= "password"><br/>
            <input type="button" value="Login">
         </fieldset>
      </form>
   </body>
</html>

Output:

Output:

HTML legend Tag

Attributes

Attribute Value Description
align top
left
right
bottom
It specifies the alignment of the legend element.

Global Attributes

The <legend> tag supports all the Global Attributes in HTML.

Event Attributes

The <legend> tag supports all the Event Attributes in HTML.

Supported Browsers

Element Chrome Firefox IE Opera Safari
<legend> Yes Yes Yes Yes Yes

Leave a Comment

Your email address will not be published.