HTML

HTMLFieldSetElement

HTMLFieldSetElement <fieldset>

The HTMLFieldSetElement interface provides special properties and methods (beyond the regular HTMLElement interface it also has available to it by inheritance) for manipulating the layout and presentation of <fieldset> elements. The <fieldset> tag is used to group related elements in a form. The <fieldset> tag draws a box around the related elements.

Attribute Value Description Example
disabled disabled Specifies that a group of related form elements should be disabled <form action="/action_page.php"> <fieldset disabled> <legend>Personalia:</legend> <label for="fname">First name:</label> <input type="text" id="fname" name="fname"><br><br> <label for="lname">Last name:</label> <input type="text" id="lname" name="lname"><br><br> <label for="email">Email:</label> <input type="email" id="email" name="email"><br><br> <label for="birthday">Birthday:</label> <input type="date" id="birthday" name="birthday"><br><br> <input type="submit" value="Submit"> </fieldset> </form>
form form_id Specifies which form the fieldset belongs to <form action="/action_page.php" method="get" id="form1"> <label for="favcolor">What is your favorite color?</label> <input type="text" id="favcolor" name="favcolor"> <input type="submit"> </form> <fieldset form="form1"> <legend>Personalia:</legend> <label for="fname">First name:</label> <input type="text" id="fname" name="fname" form="form1"><br><br> <label for="lname">Last name:</label> <input type="text" id="lname" name="lname" form="form1"> </fieldset>
name text Specifies a name for the fieldset <form action="/action_page.php" method="get"> <fieldset name="personalia"> <label for="fname">First name:</label> <input type="text" id="fname" name="fname"> </fieldset> <br> <button type="button" onclick="form.personalia.style.backgroundColor='yellow'"> Change background color of fieldset</button> <input type="submit"> </form>

Browser Compatibility

Element Chrome Edge Firefox Safari Opera
<fieldset> Yes Yes Yes Yes Yes