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 -

AlignSpecifies the alignment of the caption.Not supported in HTML5TopBottomLeftright

Example -

<!DOCTYPE html>
		<title>Legend tag example.. </title>
				Location: <input type="text"><br>
				Email: <input type="text"><br>
				Pincode: <input type="text">
				<input type="submit" value="Submit">

Output -

Address Location: Email: Pincode: