Latest web development tutorials

HTML form method attribute

Tag Reference HTML form HTML <form> tag

Examples

Use "get" method to submit the 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="提交">
</form>

try it"
(For more examples, see the bottom of the page)

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support method attribute.


Definition and Usage

method method specifies how to send the form data (form-data) (form data will be sent to the specified in the action attribute of the page).

Form data can be used as the form to send the URL variable (method = "get") or as a form of HTTP post transaction to send (method = "post").

About GET Notes:

  • The form data is appended to the name / value pairs to the URL
  • URL length is limited (about 3,000 characters)
  • Never use GET to send sensitive data! (In the URL is visible)
  • For the user wants to bookmark useful form submission
  • GET more suitable for non-secure data, such as the query string in the Google

Notes on POST:

  • Additional form data to a HTTP request body inside (data not shown in the URL)
  • No length restrictions
  • Forms submitted through POST can not be bookmarked

Differences between HTML 4.01 and HTML5

no.


grammar

<form method="get|post">

Property Value

描述
get 默认。将表单数据(form-data)以名称/值对的形式附加到 URL 中:URL?name=value&name=value。
post 以 HTTP post 事务的形式发送表单数据(form-data)。


Examples

More examples

Use the "post" method to submit the form
To send the form data by "post" method.


Tag Reference HTML form HTML <form> tag