HTML <form> methodAttributes
Examples
Use the "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="Submit">
</form>
Try it Yourself »
(See more examples at the bottom of the page)
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the method attribute.
Definition and Usage
The method attribute specifies how to send 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 on GET:
- Appends form-data to the URL in 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 where a user wants to bookmark the result
- GET is better suited for non-secure data, such as query strings in Google
Notes on POST:
- Appends form-data to the body of the HTTP request (data is not shown in the URL)
- Has no length limitations
- Forms submitted with POST cannot be bookmarked
Differences between HTML 4.01 and HTML5
None.
Syntax
<form method="get|post">
Attribute Values
| Value | Description |
|---|---|
| get | Default. Appends form-data to the URL in name/value pairs: URL?name=value&name=value. |
| post | Sends form-data as an HTTP post transaction. |
More Examples
Submit a form using the "post" method
Send form-data using the "post" method.
HTML <form> Tag Other Extensions