Fieldset and Legend tag
<fieldset>
and <legend>
are generally used in conjunction to display information about what the form is meant to be.
The
<fieldset>
tag, by default, makes a border around the <form>
which it belongs to and the <legend>
tag gives the title text for the fieldset of which it is a child of in the top left corner of the border generated by the <fieldset>
.
Example:
<form action="/action_page.php">
<fieldset>
<legend>Personal Information:</legend>
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname" />
<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname" />
<label for="email">Email:</label>
<input type="email" id="email" name="email" />
<label for="birthday">Birthday:</label>
<input type="date" id="birthday" name="birthday" />
<input type="submit" value="Submit" />
</fieldset>
</form>
Sample output for the above code is:
Comments
Post a Comment