form attribute
What does the form attribute change?
form="contact" makes a control part of the form with id="contact", wherever it sits on the page. It is submitted, validated and listed with that form only.
| Situation | Without form= | With form="contact" |
|---|---|---|
| Input outside the form | Not submitted | Submitted |
| Submit button outside the form | Does nothing | Submits and validates the form |
Input inside form A with form="B" | Sent with A | Sent with B only |
form="" or an id that doesn't exist | n/a | Belongs to no form, so it is never submitted |
form.elements and new FormData(form) | Only nested controls | Include the linked control too |
Sources: WHATWG HTML Standard: constructing the entry list · WHATWG HTML Standard: the form attribute




