Dofactory.com
Dofactory.com

HTML <fieldset> form Attribute

The form attribute on a <fieldset> tag specifies the form the fieldset is associated with.

The controls inside the fieldset will be submitted with that form.

The attribute value is the id of the form.

Example

#

A <fieldset> element with a form attribute. The second fieldset and its input elements are associated with the form above it.

Personal Information




Contact Information





<form action="/tutorial/action.html" method="get" id="main-form">
  <fieldset>
    <legend>Personal Information</legend>

    <input type="text" name="fname" placeholder="First name"><br /><br />
    <input type="text" name="lname" placeholder="Last name"><br /><br />

    <input type="submit" value="Submit">
  </fieldset>
</form> <br />

<fieldset form="main-form">
  <legend>Contact Information</legend>
  <input type="text" form="main-form" name="street" placeholder="Street"><br /><br />
  <input type="text" form="main-form" name="city" placeholder="City"><br /><br />
  <input type="text" form="main-form" name="country" placeholder="Country"><br /><br />
</fieldset>

Using form

The form attribute specifies the form the fieldset is associated with.

The attribute value is the id of the form.

The input fields inside the fieldset are not automatically included during form submission.

For that, each input element will need its own form attribute.


Syntax

<fieldset form="form-id">

Values

#

Value Description
form-id The id value of the form.

Browser support

Here is when form support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <fieldset>

Author: Jack Poorte
Published: Jun 20 2021
Last Reviewed: Sep 30 2023


What's your favorite/least favorite part of Dofactory?


Guides