HTML <form> method Attribute

The method attribute on a <form> tag specifies the method to use for form submission. The two possible methods are GET or POST.

Example

#

A method attribute on a <form> element. The form is submitted with the GET method. Enter data, submit, and notice the name/value pairs on the query string (browser command line).

User Information



<form action="/tutorial/action.html" method="get">
  <fieldset style="background: #f6f8ff; border: 2px solid #4238ca;">
    <legend>User Information</legend>

    <input type="text" name="firstname" placeholder="First name"><br /><br />
    <input type="text" name="lastname" placeholder="Last name"><br /><br />

    <button type="submit">Submit</button>
  </fieldset>
</form>

Using method

The method attribute specifies the method of submitting form data: GET or POST.

The GET method uses URL name/value pairs to send data. This is the default method.

The POST method use an HTTP post transaction with data in the body of the request.

Tip:  For more details on GET and POST methods see our HTTP methods Tutorial.


Syntax

<form method="GET | POST">

Values

#

Value Description
GET The default value. It sends data using URL name/value pairs which is visible. Therefore, GET should not be used when handling sensitive data (e.g. passwords, bank information).
POST Sends data using an HTTP post transaction with data in the request body, which is invisible. The POST method is more secure.

Browser support

Here is when method support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <form>
Guides