HTML Tag: fieldset
A form field set, used to group together related form controls and labels.
legend
is typically used as the first child of a fieldset
element to provide a caption for the group.
Optional Attributes
Attribute | Description | Possible values |
---|---|---|
disabled |
Disables all form controls within the field set. | None. |
name |
A unique name for the field set. | Text. |
form |
Explicitly associates the field set to a form element, which it may or may not be nested within. If absent, the field set will be associated to its form ancestor. |
Text matching the value of a form element’s id attribute. |
Global attributes |
Example
<form action="fieldsetdemo/">
<fieldset>
<legend>Personal details</legend>
<label for="yourname">Your name:</label> <input name="yourname" id="yourname">
<label for="yourage">Your age:</label> <input type="number" name="yourage" id="yourage">
</fieldset>
<fieldset>
<legend>Your address</legend>
<label for="housenumber">House number:</label> <input type="number" name="housenumber" id="housenumber">
<label for="street">Street:</label> <input name="street" id="street">
<label for="postcode">Zip code / post code:</label> <input name="postcode" id="postcode">
</fieldset>
<input type="submit">
</form>