The <form> tag

The <form> tag groups input elements (input, select, textarea, etc.) into a single form for submitting data.

Syntax

<form action="/submit" method="post">...</form>

Attributes

action The URL the form data is submitted to.
method "get" (data in the URL) or "post" (data in the request body).
enctype The data encoding format; file uploads require multipart/form-data.
novalidate Disables the browser's built-in HTML5 field validation before submission.

Example

<form action="/subscribe" method="post">
  <label for="email">Email</label>
  <input type="email" id="email" name="email" required>
  <button type="submit">Subscribe</button>
</form>

Notes

  • A button inside a form without an explicit type="button" defaults to type="submit" and submits the form.
  • File inputs (input type="file") require the form to have enctype="multipart/form-data".

Accessibility

  • Every input should have an associated label (via for/id, or by wrapping it).

Related tools