HTML <input> form attribute

Definition and Usage

form The attribute specifies the form to which the <input> element belongs.

Example

Input fields outside of HTML forms (but still part of the form):

<form action="/action_page.php" id="form1">
  <label for="fname">Name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <input type="submit" value="Submit">
</form>
<label for="lname">Surname:</label>
<input type="text" id="lname" name="lname" form="form1">

Try It Yourself

Syntax

<input form="form_id">

Attribute Value

Value Description
form_id

Specifies the form element to which the <input> element belongs.

The value of this attribute must be equal to the id attribute of the <form> element in the same document.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support 5.1 10.6