HTML legend Tag

HTML legend Tag defines the caption or title for the fieldset tag. The legend tag must be first child of it's parent element.

Syntax of HTML legend Tag

The Syntax of HTML legend Tag is shown below, It has both starting tag and ending tag.

<legend>Biodata Form</legend>

Usage of HTML legend Tag

HTML legend Tag is used to define the title or caption for it's parent element. Most commonly it is used inside the fieldset tag to define it's caption.

HTML legend Tag is the first tag inside the fieldset tag.

HTML legend Tag is a block level element.

Example of HTML legend Tag

Simple example of HTML legend Tag is shown below.

<form action="/action.php">
 <fieldset>
  <legend>Student Form</legend>
  <label for="name">Name:</label>
  <input type="text" id="name" name="uname"><br>
  <label for="email">Email:</label>
  <input type="email" id="email" name="uemail"><br>
  <label for="number">Contact:</label>
  <input type="number" id="number" name="unumber"><br><br>
  <input type="submit" value="Submit">
 </fieldset>
</form>

Output

Student Form



In above example we have a simple student information form. The legend tag is used in this form inside the fieldset tag to define the title or caption, which also explains the purpose of the form.

Browser Support for HTML legend Tag

HTML legend Tag is supported by all major browsers including Safari and Internet Explorer.

Global Attributes Support in HTML legend Tag

The HTML legend Tag supports all Global Attributes.

Event Attributes Support in HTML legend Tag

The HTML legend Tag supports all Event Attributes.

HTML legend Tag Video

Watch our video on HTML legend Tag.

HTML Comment Tag HTML Doctype Tag HTML anchor Tag HTML abbr Tag HTML acronym Tag HTML address Tag HTML applet Tag HTML area Tag HTML article Tag HTML aside Tag HTML audio Tag HTML b Tag HTML base Tag HTML basefont Tag HTML bdi Tag HTML bdo Tag HTML big Tag HTML blockquote Tag HTML body Tag HTML br Tag HTML Button Tag HTML Canvas Tag HTML Caption Tag HTML Center Tag HTML Cite Tag HTML Code Tag HTML Col Tag HTML colgroup Tag HTML data Tag HTML datalist Tag HTML dd Tag HTML del Tag HTML details Tag HTML dfn Tag HTML dialog Tag HTML dir Tag HTML div Tag HTML dl Tag HTML dt Tag HTML em Tag HTML embed Tag HTML fieldset Tag HTML figcaption Tag HTML figure Tag HTML font Tag HTML footer Tag HTML form Tag HTML frame Tag HTML frameset Tag HTML Heading Tags HTML head Tag HTML header Tag HTML hr Tag HTML html Tag HTML i Tag HTML iframe Tag HTML img Tag HTML input Tag HTML ins Tag HTML kbd Tag HTML label Tag HTML legend Tag HTML li Tag HTML link Tag