The <form> element represents a section with interactive controls for submitting information — typically <input>, <textarea>, <select>, and <button>, each paired with a <label>.
Set action to the URL that handles the data, and method to get or post (or dialog inside a <dialog>). You can style validity with :valid / :invalid on the form.
Baseline · Widely available.
Not deprecated. Core form support has been stable across browsers since about July 2015 (and much earlier in practice).
Deprecated: accept on <form>.
Do not use the form-level accept attribute. Put accept on file <input type="file"> instead (MDN).
Syntax
HTML Syntax
syntax.html
<form action="url" method="get|post">…</form>
Both start and end tags are required. Content is flow content, but not another nested <form>.
Try submit empty — the browser blocks and shows a message.
Use novalidate on the form only when you intentionally skip HTML checks.
Edge Cases & Pitfalls
Most form bugs are missing names, missing labels, or the wrong method for the job.
a11y
Labels beat placeholders
Placeholders disappear when typing and are easy to miss. Always provide a real <label>.
data
Controls need name
Without a name, a successful control is not included in the submitted data set.
structure
No nested forms
A <form> must not contain another <form>. Split forms or use the form attribute on controls.
method
GET is not for secrets
Query strings appear in history, logs, and referrers. Use POST (over HTTPS) for passwords and private data.
files
File uploads need multipart
With <input type="file">, set method="post" and enctype="multipart/form-data".
Compatibility
Browser Support
The <form> element is core HTML in every browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
<form>
Widely available since about July 2015 (and long before). Chrome, Firefox, Safari, Edge, and Opera fully support form submission attributes and native validation.
98%Global support (approx.)
Google ChromeAll
Full support
Mozilla FirefoxAll
Full support
Apple SafariAll
Full support
Microsoft EdgeAll
Full support
OperaAll
Full support
Samsung InternetAll
Full support
Internet ExplorerAll
Supported
<form>Widely supported
Bottom line: Safe everywhere for classic form posts. Always validate and sanitize on the server regardless of browser features.
Remember
Key Takeaways
Role:<form> groups controls and defines how data is submitted.
Wire:action + method; every successful control needs a name.
Access: pair every input with a visible <label>.
Choose method wisely: GET for safe queries; POST for changes and private data.
One line: a good form has clear labels, named controls, and the right action / method for the job.
UA style
Default CSS Settings
Forms are block-level containers. Exact UA styles for controls vary; a simple idea:
default.css
form {
display: block;
margin-top: 0;
}
Keep study CSS minimal. Style spacing and labels for readability; never remove focus outlines on controls.
Frequently Asked Questions
The form element groups interactive controls (inputs, buttons, selects, and more) so users can enter data and submit it to a URL defined by action, using an HTTP method such as get or post.
GET (default) appends data to the action URL as a query string — good for safe searches with no side effects. POST sends data in the request body — better for creating or changing data, passwords, and larger payloads.
Yes for accessibility. Associate each control with a label using for/id or by wrapping the control. Placeholder text is not a substitute for a visible label.
No. Nested form elements are invalid. Keep one form per submission group, or use the form attribute on controls to associate them with a form elsewhere.
The Boolean novalidate attribute skips built-in HTML constraint validation on submit. Use it carefully — validation still matters on the server.
When the form includes a file input (type="file"). Otherwise the default application/x-www-form-urlencoded is usually fine for text fields.