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

HTML input formmethod attribute

HTML formmethod attribute

HTML input Tag Reference HTML tag

Example

The second submit button overrides the form's HTTP method:

First name:

Last name:

Try it »


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Internet Explorer 10, Firefox, Opera, Chrome, and Safari support the formmethod attribute.

**Note:** Internet Explorer 9 and earlier versions do not support the the formmethod attribute of the tag.


Definition and Usage

The formmethod attribute defines the HTTP method used to send form data to the action URL.

The formmethod attribute overrides the

elements' method attribute.

**Note:** The formmethod attribute is used with type="submit" and type="image".

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

Notes on the "get" method:

  • This method appends form data to the URL as name/value pairs
  • This method is useful for form submissions that users want to bookmark
  • The length of a URL is limited (the limit varies by browser), so you cannot be sure that all form data will be transmitted correctly
  • Never use the "get" method to send sensitive data! (Such as passwords or other sensitive information, which are visible in the browser's address bar.)

Notes on the "post" method:

  • This method sends form data as an HTTP post transaction
  • Forms submitted via the "post" method cannot be bookmarked
  • The "post" method is more secure than "get", and "post" has no length limit

Differences between HTML 4.01 and HTML5

The formmethod attribute is new in HTML5.


Syntax

Attribute values

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

HTML input Tag Reference HTML tag