What Form Method Tells Your Web Browser In HTML: An Easy Tutorial

Disclosure: Your support helps keep the site running! We earn a referral fee for some of the services we recommend on this page. Learn more
Attribute of
HTML Form Code For Beginners (And When To Use It)
What does What Form Method Tells Your Web Browser In HTML: An Easy Tutorial do?
Tells the browser how to send form data to a web server.

The method attribute of the form element tells the browser how to send form data to a web server.

Example Usage

<form action="fileupload.php" method="post" enctype="multipart/form-data"> <p>Please select the file you would like to upload.    <input type="file" name="upload">    <br>    <input type="submit" value="Upload File"> </form> 

<form method=”GET”>

The method attribute of the form element tells the web browser how to send form data to a server. Specifying a value of GET means the browser will add the form contents to the end of the URL. This offers a number of advantages for simple forms. It allows the browser to cache the results of the form submission, and it also allows the user to bookmark the page once the form has been submitted. As such, GET is generally used for simple forms where security is not a concern.

Restrictions of GET

GET results in the entire contents of the submission being visible in the URL. If your form contains sensitive data, you should specify a value of POST for the method attribute. Since GET appends the form data to the current URL, it can only be used where the contents of the submission (including the complete URL) will result in a string that is 2048 characters long, or less. This is the maximum length of a URL. GET can only be used to send ASCII data.

<form method=”POST”>

The method attribute of the form element tells the web browser how to send form data to a server. Specifying a value of POST means the browser will send the data to the web server to be processed. This is necessary when adding data to a database, or when submitting sensitive information, such as passwords.

Restrictions of POST

When data is sent using POST, submitting the form twice will result in a duplicated entry. This can be a problem if the form is linked to a membership, purchase, or other one-time action. This is why users cannot bookmark the results of a form submission if the method is POST.

Values of the method Attribute

Value NameNotes
GETSends form data via a URL string
POSTSends form data via the server

All attributes of form Element

Attribute nameValuesNotes
target_self
_blank
Specifies the browser context in which the form’s response should be displayed.
actionSpecifies a URL to which the form’s data is sent when submitted.
enctype
methodGET
POST
Tells the browser how to send form data to a web server.
onSubmitRuns a script when the Submit button is clicked.
onResetRuns a script when the Reset button is clicked.
name
Claire is seasoned technical writer, editor, and HTML enthusiast. She writes for HTML.com and runs a content agency, Red Robot Media.

Browser Support for method

iefirefoxchromeedgesafariopera
AllAllAllAllAllAll