HTML » Tags » legend

Version: 4.0

Compability: Explorer 4, 5  Netscape 6

Syntax:
<legend> ... </legend>

The <legend> tag is used to create a caption for the form elements associated with a fieldset group. Therefore, this tag can only be used inside the fieldset element. The browser is supposed to render the legend caption in a special manner to accentuate the appearance.

This tag is one of three tags implemented in 4.0 that help set the appearance of a form. The other two are fieldset and label.
 
However, these three tags are poorly implemented by most browsers.
 
The closing tag is mandatory.
 

Examples

Code:
<form>
<fieldset>
<legend>Please Enter Your Name</legend>
<label for="firstname">First Name</label><input type="text" id="firstname">
<br>
<label for="lastname">Last Name</label><input type="text" id="lastname">
</fieldset>
</form>
Output:
Please Enter Your Name
Language(s): HTML

See Also: