HTML form element

Reference for the HTML form element: content model, default action and method, GET versus POST (not encryption), and how controls are submitted.

タグページの本文は現在英語です。

The form element groups associated controls for submission. Its content model is flow content, but it must not contain another form element. Both start and end tags are required. This page deepens the catalog card for <form> and links to input and button.

The default method is GET. The default action is the current document URL (an empty or missing action). The default enctype is application/x-www-form-urlencoded. multipart/form-data is required for file uploads. method="dialog" is for a form inside a dialog element and is covered on the dialog page rather than here.

These examples have no third-party action URL and do not run a network request. If you copy them into a file and activate submit in a browser, a GET form with no action may add a query string to the current document URL. That is still not a server API, and it is not encryption.

Official sources: MDN <form> element and the WHATWG HTML Living Standard. Fragments were checked with Python 3.13 html.parser. That parser builds an element tree; it is not a WHATWG conformance checker, and this is not a browser or accessibility test.

HTML tag catalog → · HTML tutorial overview →

Purpose, content model, and defaults

A form submits the values of its successful controls. Controls normally live inside the form. A control may also use a form attribute whose value is the id of a form elsewhere in the same document.

Do not nest form elements. The first example is a labelled practice form with no remote endpoint.

A labelled form with the default action

<form action method="get" enctype autocomplete novalidate>

A form owns labelled controls. A missing action means the current document, not a hidden server.

AttributeDescription
actionURL of the form processor. Missing or empty means the current document URL. Do not point practice forms at a third-party endpoint.
methodget (default) appends the query to the action URL. post puts the payload in the request body. Neither one encrypts the data.
enctypeEncoding for POST (and a few other cases). The default is application/x-www-form-urlencoded. Use multipart/form-data when the form contains a file input.
autocompleteon (default) or off, as a default for controls in the form.
novalidateBoolean. If present, the form skips constraint validation on submit.
nameA name for the form in the document's forms collection. It is not a submitted field.
targetBrowsing context for the submission response, analogous to a target on a link.
  • This form has no action attribute and no https:// destination. It is a markup example, not a live signup or payment form.
html
<form>
  <p>
    <label for="email">Email</label>
    <input id="email" name="email" type="email" required>
  </p>
  <p>
    <label for="title">Project title</label>
    <input id="title" name="title" type="text">
  </p>
  <button type="submit">Check email</button>
</form>

What this markup means

Each control has a name so it can be a successful field. Labels are associated with for and id. required is a client constraint only. There is no remote action, so this example does not submit data to a third party.

Related: Tag catalog: <form>, <input>, <button>, <label>, <select>, <textarea>, <dialog>, HTML tutorial: Label a form

MDN documentation → · WHATWG HTML Standard →

GET versus POST is not encryption

GET places name/value pairs in the action URL query string. That makes the submission bookmarkable and more visible in history and logs. POST places the payload in the request body, which is appropriate for requests that change server state and for larger or less visible payloads such as files.

POST is not confidentiality. Neither GET nor POST encrypts form data by itself. Encryption in transit is the job of HTTPS (TLS) on the connection. A POST over plain HTTP is still readable on the network. Do not put secrets, passwords, or session tokens into a GET query string, and do not treat POST as a security boundary.

method="get" and method="post"

<form method="get">
<form method="post">

GET writes a query string. POST uses a request body. Neither method is encryption.

AttributeDescription
method="get"Default. Successful controls are encoded into the action URL.
method="post"Successful controls are sent in the request body. Still not encrypted unless the connection uses HTTPS.
  • Neither form has a third-party action. No request is sent from this documentation page.
html
<form method="get">
  <label for="q">Search term</label>
  <input id="q" name="q" type="search">
  <button type="submit">Search</button>
</form>
<form method="post">
  <label for="note">Practice note</label>
  <input id="note" name="note" type="text">
  <button type="submit">Save note</button>
</form>

What this markup means

The first form would, in a browser, add ?q=... to the current URL because method is get and action is omitted. The second would send a request body if a user agent submitted it. This page does not submit either form, and neither method should be described as encrypting the note or the search term.

Related: <input>

MDN documentation → · WHATWG HTML Standard →

Successful controls and security

Only successful controls are submitted. A control needs a name. disabled controls are not successful. Unchecked checkboxes and radio buttons are not successful. A submit button is successful only if it is used to submit the form (or is the implicit default).

Client constraint validation, autocomplete, and hidden fields are not access control. Anyone can build an HTTP request that omits or alters fields. Validate and authenticate on the server. These documentation examples must not be pointed at a third-party action that would collect real personal data.