HTML <button> form Attribute
Definition and Usage
form
Attribute specifies the form to which the button belongs.
The value of this attribute must be equal to the id attribute of the <form> element in the same document.
Example
Button located outside the form (but still part of the form):
<form action="/action_page.php" method="get" id="form1"> <label for="fname">First Name:</label> <input type="text" id="fname" name="fname"><br><br> <label for="lname">Last Name:</label> <input type="text" id="lname" name="lname"> </form> <button type="submit" form="form1" value="Submit">Submit</button>
Syntax
<button form="form_id">
Attribute Value
Value | Description |
---|---|
form_id |
Specifies the form element to which the <button> element belongs. The value of this attribute must be the id attribute of the <form> element in the same document. |
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
10.0 | 16.0 | 4.0 | 5.1 | 9.5 |
Tip:The form attribute of the <button> element is a new attribute in HTML 5.