HTML fieldset Tag is used to combine the group of elements that are related to each other, inside the HTML form element. HTML fieldset tag is used with legend tag.
Table of Contents
Syntax of HTML fieldset Tag
The Syntax of HTML fieldset Tag is shown below, It has both starting and ending tags.
<fieldset>
// related tags
</fieldset>
Usage of HTML fieldset Tag
HTML fieldset Tag combines the group of related html elements that are present inside the form tag.
HTML fieldset Tag is used with the legend tag which is used for the caption of the fielset HTML element.
You can use form attribute inside the fieldset tag to specify which form the fieldset belongs to.
HTML fieldset Tag is a block level element.
By default HTML fielset tag has a border around it.
Example of HTML fieldset Tag
Simple example of HTML fieldset Tag is shown below.
<form>
<fieldset>
<legend>Student Form:</legend>
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<br>
<br>
<label for="class">Class:</label>
<input type="text" id="class" name="class">
<br>
<br>
<label for="email">Email:</label>
<input type="email" id="email" name="email">
<br>
<br>
<input type="submit" value="Submit">
</fieldset>
</form>
Output
The output of above code is shown below.
Browser Support for HTML fieldset Tag
HTML fieldset Tag is supported by all major browsers including Safari and Internet Explorer.
Global Attributes Support in HTML fieldset Tag
The HTML fieldset Tag supports all Global Attributes.
Event Attributes Support in HTML fieldset Tag
The HTML fieldset Tag supports all Event Attributes.
HTML fieldset Tag Video
Watch our video on HTML fieldset Tag.