This <legend> element inserts a descriptive
caption in the container box of a
<fieldset>
element.
You use this element to define the group of fields contained in the <fieldset>
element.
<legend> |
Yes | Yes | Yes | Yes | Yes |
The "align" attribute is not supported in HTML5.
Attribute | Value | Description |
---|---|---|
align | top bottom left right |
Not supported in HTML5. Set the caption alignment |
The <legend> tag supports the Global Attributes in HTML.
The <legend> tag supports the Event Attributes in HTML.
legend { display: block; padding-left: 2px; padding-right: 2px; border: none; }
A demo showing how to use <legend> tag.
<html>
<body>
<form name="form1" method="post" action="">
<p>
<fieldset align="center">
<legend>Credit Card Information:</legend>
<input type="text"
name="textfield"
value="Name"
size="60"/><br/>
<input type="text"
name="textfield2"
value="Exp. date"
size="50"/><br/>
<input type="text"
name="textfield3"
value="Type"
size="65"/><br/>
<input type="text"
name="textfield4"
value="Number"
size="45"/>
</fieldset>
</p>
</form>
</body><!-- w w w . j av a2s. c om-->
</html>