<form>: The FORM Element
Last updated: 2026-10-13
<form>The FORM Element
The <form> element is the container for collecting and submitting user data. It wraps form controls (<input>, <select>, <textarea>…), with action for the submit URL and method for the HTTP method.
| Category | Forms |
|---|---|
| Content Model | Flow content (no nested <form>) |
| Allowed Parents | Any element that accepts flow content |
| Content Tag | Yes — requires closing </form> tag |
| Status | Standard |
📝 Syntax
<form action="submit-url" method="post">
Form controls
<input type="submit" value="Submit">
</form>
⚙️ Attributes
This element supports the global attributes plus the following:
| Attribute | Value | Description |
|---|---|---|
action | URL | The URL where form data is submitted. Default: |
method | Keyword | The HTTP method used to submit.
|
name | Text | Form name for JavaScript reference. |
autocomplete | Keyword | Whether browser autofill is enabled.
|
novalidate | Boolean | Skip HTML5 form validation on submit. |
target | Keyword | Where to display the submission result. Default: |
▶ Example
Edit the code below and see the live result in the playground:
🌐 Browser Support
| Browser | |||||
|---|---|---|---|---|---|
| <form> | ✓ v1 | ✓ v12 | ✓ v1 | ✓ v1 | ✓ v1 |
| Supported in all major browsers | |||||
Tip: Pair form controls with <label> for accessibility and a larger click target.
❓ FAQ
QShould form use get or post?
AGET appends data to the URL — bookmarkable, length-limited — and fits read-only operations such as search and filtering. POST sends data in the request body and fits operations that change data: registration, login, payment. Anything involving passwords or sensitive data is always POST.
QDoes a form need a submit button?
ANot strictly: pressing Enter submits single-input forms in most browsers, and JS can call
form.requestSubmit() or form.submit(). But for usability and accessibility an explicit submit button remains best practice.QCan the action attribute be omitted?
AYes — when omitted, the form submits to the current page URL (HTML5 behavior). In single-page apps, forms commonly call
preventDefault() to intercept submission and send data with fetch instead; with or without action, interception works the same.