HTML <fieldset>
Tag
The <fieldset>
tag in HTML is used to group together related form elements within a form. It helps in organizing the form layout and visually grouping related input elements together.
Example:
In the example below, we have a simple form with two text input fields grouped using the <fieldset>
tag:
<form>
<fieldset>
<legend>User Information</legend>
Name: <input type="text" name="name"><br>
Email: <input type="email" name="email">
</fieldset>
</form>
When rendered in a browser, the form will look like this:
Attributes of the <fieldset>
Tag:
Attribute | Description |
---|---|
disabled |
Specifies that the <fieldset> element should be disabled |
form |
Specifies which form the <fieldset> element belongs to |
name |
Specifies the name of the <fieldset> element |
These attributes can be used to customize the behavior and appearance of the <fieldset>
tag in HTML forms.