The form attribute links a form-associated control to a <form> by matching that form’s id. It works on button, fieldset, input, object, output, select, and textarea.
By default, a control joins its nearest ancestor form. With form, you can place controls (or a submit button) outside the form markup — or override an ancestor form — and still include them in that form’s submission.
Baseline · Widely available.
Not deprecated and not experimental. Stable across modern browsers since about July 2015.
Not inherited.
Setting form on a <fieldset> does not associate nested inputs. Each control needs its own form value or must live inside the target form.
Syntax
HTML Syntax
syntax.html
<input form="form_id">
form_id must equal the id of a <form> in the same document. Other values are ignored.
Values
Attribute Values
One value: the form’s id. Common patterns:
Pattern
Description
Try it
Control outside form
An input / select / textarea placed outside <form> still submits with it
Override:form beats the nearest ancestor form when both apply.
Script: read element.form; write with setAttribute("form", id).
One line:form ties a control to a form by id — layout can stay flexible without losing submit behavior.
Frequently Asked Questions
It associates a form-associated control with a form element by matching that form’s id. The control then belongs to that form for submission and validation, even if it is not nested inside the form.
button, fieldset, input, object, output, select, and textarea. The form element itself does not use this attribute — it provides the id that controls reference.
The id of a form in the same document. Any other value is ignored. If no matching form exists, the control is not associated with a form.
Yes. A button with type=submit and form="formId" submits the referenced form, including its associated fields and constraint validation.
No. The attribute is not inherited. Each nested control needs its own form attribute or must sit inside the target form.
element.form returns the associated HTMLFormElement (read-only). To change the association, use setAttribute("form", "formId") or removeAttribute("form").