<legend>

Browser
  • IE
  • Cr
  • Sf
  • Fx
  • O

The LEGEND element defines a caption for a fieldset.


<legend>fieldset legend</legend>

The LEGEND element is placed immediately after the FIELDSET start tag.

<form method="POST" action="example.cgi">
<fieldset>
<legend>fieldset legend</legend>
<p>Name : <input type="text" mame="name" size="30"></p>
</fieldset>
</form>

Example


<form method="POST" action="example.cgi">

<fieldset>
<legend>Your Contact Information</legend>

<p>Name :<br>
<input type="text" mame="name" size="30"></p>
<p>Telephone number :<br>
<input type="text" mame="telephone" size="30"></p>
<p>E-mail address :<br>
<input type="text" mame="email" size="30"></p>

</fieldset>

<fieldset>
<legend>Your Feedback</legend>

<p>Question 1 :
<input type="radio" name="q1" value="yes"> Yes
<input type="radio" name="q1" value="no"> No
</p>
<p>Question 2 :
<input type="radio" name="q2" value="yes"> Yes
<input type="radio" name="q2" value="no"> No
</p>
<p>Question 3 :
<input type="radio" name="q3" value="yes"> Yes
<input type="radio" name="q3" value="no"> No
</p>

</fieldset>

<p>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</p>

</form>

Output
Your Contact Information

Name :

Telephone number :

E-mail address :

Your Feedback

Question 1 : Yes No

Question 2 : Yes No

Question 3 : Yes No

This form cannot submit because of a sample.

Example of applying CSS to the FIELDSET element

<fieldset style="margin-bottom: 20px; padding: 20px; background-color: #ffffff;">

Output
Your Contact Information

Name :

Telephone number :

E-mail address :

Your Feedback

Question 1 : Yes No

Question 2 : Yes No

Question 3 : Yes No

This form cannot submit because of a sample.