Advertisement
Home Open Editor ❯

HTML <input> form Attribute

Example

<form action="action.php" id="form1">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname">
  
  <input type="submit" value="Submit">
</form>

<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname" form="form1">

Try this code ❯

Meaning

The form attribute should be set to a string that corresponds to the id of the form element that an interactive control such as a button is associated with.

This allows form elements in one form to trigger actions in others.

The form attribute lets you place an input anywhere in the document but have it included with a form elsewhere in the document.

Note: An input can only be associated with one form.


Standard Syntax

HTML: <input form="formId">

XHTML: <input form="formId"/>


Advertisement

Attribute Values

Value Description
formId The form element the <input> element belongs.
Home Open Editor ❯
Advertisement