HTML <input> form Attribute

The form attribute on an <input> tag specifies the form the input element is assocaited with. The input element will be included during form submission.

Example

#

A form attribute on an <input> field.
Although outside the form, this input field is included during form submission.

Personal Information


<form action="/tutorial/action.html" id="myform">
  <fieldset style="background: #f6f8ff; border: 2px solid #4238ca;">
    <legend>Personal Information</legend>
    <input type="text" name="firstname" placeholder="First name">

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

<input form="myform" type="text" name="lastname" placeholder="Last name">

Using form

The form attribute specifies the form the input element is associated with.

The attribute value is the id of the form.

Once associated with a form, the input element is included during form submission.


Syntax

<input form="form-id">

Values

#

Value Description
form-id The id of a form element.

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
10.6 Jul 2010
Safari
5.1 Oct 2011

You may also like

 Back to <input>
Guides