Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML form method Attribute

HTML
The method attribute

HTML form Tag Reference HTML Tag

Example

Using the "get" method to submit a form:

<form action="demo_form.html" method="get" First name>

: <

input

type

=

"

text

"

name

=

"

fname

"

<

br

Last

name

: <

input

type

=

"

text

"

name

=

"

lname

"

<br>
<input type="submit" value="Submit" form>

Try it »

(More examples are at the bottom of the page)


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the method attribute.


Definition and Usage

The method attribute specifies how to send the form data (form-data) (the form data is sent to the page specified in the action attribute).

Form data can be sent as URL variables (method="get") or as an HTTP post transaction (method="post").

Notes about GET:

  • Append the form data to the URL as name/value pairs
  • The length of a URL is limited (about 3000 characters)
  • Never use GET to send sensitive data! (it is visible in the URL)
  • Useful for form submissions that users want to bookmark
  • GET is better suited to non-secure data, such as query strings in Google

Notes about POST:

  • Append the form data to the body of the HTTP request (the data is not displayed in the URL)
  • No length limit
  • Forms submitted via POST cannot be bookmarked

Differences between HTML 4.01 and HTML5

none.


Syntax

Attribute values

Value Description
get Default. Append the form data (form-data) to the URL as name/value pairs: URL?name=value&name=value.
post Send the form data (form-data) as an HTTP post transaction.

More examples

Using the "post" method to submit a form
Send the form data via the "post" method.


HTML form Tag Reference HTML tag