--- url: "https://web.dev/learn/html/forms" titulek: "Forms | web.dev" h1: "Forms Stay organized with collections Save and categorize content based on your preferences." popis: "An overview of forms in HTML." jazyk: "en" kanonicka: "https://web.dev/learn/html/forms" drobecky: ["web.dev", "Resources", "HTML"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 01:46:59" znaku: 30525 slov: 4499 kodovani: "iso-8859-2" sha256: "3a51251eaf0ad55d1237f064f279ec9ea2339161332e97bbfc367222ea9ccd40" --- Forms Stay organized with collections Save and categorize content based on your preferences. Most sites and applications include a web form. Joke sites, like [DoWebsitesNeedToLookExactlyTheSameInEveryBrowser.com](http://dowebsitesneedtolookexactlythesameineverybrowser.com/), may not have a form, but even [MachineLearningWorkshop.com](https://machinelearningworkshop.com/) (MLW), which originated as an April Fool's day joke, has a form, albeit a fake one. MLW's main "call to action" is a registration form for machines to sign up for a workshop. This form is contained in a `
` element. The [HTML `` element](https://developer.mozilla.org/docs/Web/HTML/Element/form) identifies a document [landmark](https://developer.mozilla.org/docs/Web/Accessibility/ARIA/Roles#3._landmark_roles) containing interactive controls for submitting information. Nested in a `` you'll find all the interactive (and non-interactive) form controls that make up that form. HTML is powerful. This section focuses on the power of HTML, covering what HTML can do without adding JavaScript. Using form data client-side to update the UI in some way generally involves [CSS](https://codepen.io/jcoulterdesign/pen/NOMeEb) or JavaScript, which is not discussed here. There is an entire [Learn Forms](/learn/forms) course. We won't duplicate that section here, but we will introduce several form controls and the HTML attributes that empower them. With forms, you can enable users to interact with your website or application, validate the information entered, and submit the data to a server. HTML attributes can enable requiring the user to select form controls or enter a value. HTML attributes can define specific criteria that the value must match to be valid. When the user tries to submit the form, all the form control values go through client-side constraint validation and can prevent submission until the data matches the required criteria; all without JavaScript. You can also turn this feature off: setting the [`novalidate`](https://developer.mozilla.org/docs/Web/HTML/Element/form#attr-novalidate) attribute on the `` or, more often, `formnovalidate` on a button, saving the form data for later completion, prevents validation. Submitting forms Forms are submitted when the user activates a submit button nested within the form. When using `` for buttons, the 'value' is the button's label, and is displayed in the button. When using `` For a very simple form, you need a `` element, with some form inputs inside, and a submit button. However, there is more to submitting a form than that. The attributes of the `` element set the [HTTP method](/learn/forms/form-element#how_is_the_data_transferred) by which the form is submitted and the URL that processes the form submission. Yes, forms can be submitted, processed, and a new page can be loaded without any JavaScript. The [`` element](/learn/forms/form) is that powerful. The `` element's [`action`](https://developer.mozilla.org/docs/Web/HTML/Element/form#attr-action) and [`method`](https://developer.mozilla.org/docs/Web/HTML/Element/form#attr-method) attribute values define the URL that processes the form data and the HTTP method used to submit the data, respectively. By default, the form data gets sent to the current page. Otherwise, set the `action` attribute to the URL of where the data should be sent. The data sent is made up of name/value pairs of the form's various form controls. By default, this includes all the form controls nested within the form that have a `name`. However, with the `form` attribute, it is possible to include form controls outside the `` and to omit form controls nested within the ``. Supported on form controls and `
`, the `form` attribute takes as its value the `id` of the form the control it is associated with, not necessarily the form it is nested in. This means form controls don't need to be physically nested in a ``. The `method` attribute defines the HTTP protocol of the request: generally `GET` or `POST`. With `GET`, the form data is sent as a parameter string of `name=value` pairs, appended to the `action`'s URL. With `POST`, the data is appended to the body of the HTTP request. When sending secure data, such as passwords and credit card information, always use `POST`. There is also a `DIALOG` method. If a `` is within a ``, submitting the form will close the dialog; there is a submit event though the data is neither cleared nor submitted. Again, without JavaScript. This is discussed in [the dialog section](/learn/html/dialog). Just note, because this doesn't submit the form, you probably want to include both `formmethod="dialog"`and `formnovalidate` on the submit button. Form buttons can have more than the attributes described at the start of this section. If the button includes a `formaction`, `formenctype`, `formmethod`, `formnovalidate`, or `formtarget` attribute, the values set on the button activating the form submission take precedence over the `action`, [`enctype`](/learn/forms/form#enable_users_to_submit_files), `method`, and [`target`](/learn/html/attributes) set on the ``. Constraint validation occurs prior to form submission, but only if there is neither a `formnovalidate` on the activated submit button nor a `novalidate` on the ``. To capture which button was used to submit a form, give the button a `name`. Buttons with no name or value don't get sent with the form data on form submission. After submitting the form When the user submits a completed online form, the names and values of the relevant form controls get submitted. The name is the value of the `name` attribute. The values come from the contents of the `value` attribute or the value entered or picked by the user. The value of a `