References

Beginner-friendly references for web development, with live, editable examples.

The HTML method attribute

Attribute All modern browsers Updated
Quick answer

The HTML method attribute specifies the HTTP method used to submit the form. It is used on the <form> element.

Overview

The method attribute specifies the HTTP method used to submit the form. It applies to the <form> element.

Use get for idempotent queries (the data goes in the URL) and post for changes or sensitive data. dialog closes a parent <dialog> and reports the submission instead of navigating.

Syntax

<form method="post" action="/save"> … </form>

Values

Value
get | post | dialog

Best practices

  • Use method="post" for submissions that change data and method="get" for searches and filters.
  • Set enctype="multipart/form-data" when the form uploads files.
  • Prefer native validation over novalidate; only skip validation deliberately.
  • Always process and re-validate the submission on the server.

Frequently asked questions

What does the method attribute do?
Sets the HTTP method for form submission.
What is the difference between GET and POST?
GET appends the data to the URL (good for searches and bookmarkable results); POST sends it in the request body (used for actions that change data).
How do I let a form upload files?
Set method="post" and enctype="multipart/form-data" on the <form>.
Which elements use the method attribute?
It is an element-specific attribute, used on the <form> element.