Summary -
In this topic, we described about the below sections -
Caption or title or explanatory caption for <fieldset> element in the form. The <legend> tag used to specify caption for the parent element. The <legend> tag should appear immediately after the opening <fieldset> tag.
The tag can be specified like <legend></legend> with the title/caption in between the opening and closing tags. The "align" attribute supported in HTML4.01 is not supported in HTML5.
Syntax -
<legend>HTML text here </legend>
Optional Attributes -
Attribute | Description | Values |
---|---|---|
Align | Specifies the alignment of the caption.Not supported in HTML5 | TopBottomLeftright |
Example -
<!DOCTYPE html>
<html>
<head>
<title>Legend tag example.. </title>
</head>
<body>
<form>
<fieldset>
<legend>Address</legend>
Location: <input type="text"><br>
Email: <input type="text"><br>
Pincode: <input type="text">
<input type="submit" value="Submit">
</fieldset>
</form>
</body>
</html>