HTML <input> form Attribute

Last Updated : 25 May, 2026

The form attribute is used to associate an <input> element with a specific <form> element. It allows the input field to be connected to a form even if it is placed outside the form tag.

  • Links an input element to a form using the form’s id value.
  • Allows input fields to exist outside the <form> element while still being submitted with the form.
  • Helps in creating flexible and well-structured form layouts

Syntax:

<input form="form_id">

Attribute Value: The form attribute contains a single value called form_id, which specifies the id of the <form> element the input belongs to.

Example: Illustrates the use of form attribute in <input> element. 

html
<!DOCTYPE html>
<html>
  <body>
    <h1>GeeksforGeeks</h1>

    <h2>
        HTML &lt;input&gt; form Attribute
    </h2>

    <form id="myGeeks"></form>
    <br />
    Name:
    <input type="text" id="btn" 
           name="myGeeks" form="myGeeks"/>
  </body>
</html>
Comment