Dofactory.com
Dofactory.com
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

HTML method="get"

A method="get" attribute value specifies that the form data will be submitted as name/value pairs on the query string.

It is sent using the HTTP GET method.

Example

#

A method="get" on a <form> tag.
Enter data, submit, and notice the name/value pairs on the url (browser command line).

Address Information





<form action="/tutorial/action.html" method="get">
  <fieldset style="background: #f6f8ff; border: 2px solid #4238ca;">
    <legend>Address Information</legend>

    <input type="text" name="street" placeholder="Street"><br /><br />
    <input type="text" name="city" placeholder="City"><br /><br />
    <input type="text" name="country" placeholder="Country"><br /><br />

    <button type="submit">Submit</button>
  </fieldset>
</form>

Using method="get"

The method attribute specifies the method to use for form submission.

The method="get" value sends form data to the server by appending it to the page request.

This method is mostly used when requesting data from the server which requires certain parameter or queries.


Syntax

<form method="GET">

Elements that accept method="get"

Only one element uses the method attribute with the get value.

Elements Description
<form> Specifies an HTML form -- see example above

Features of the get method

Data is easily visible on the url

Data remains in the browser history

Data and associated query can be cached and reused

The query can be bookmarked


Restrictions of the GET method

The GET method is used to request data -- not modify it

Data should never include sensitive information such as passwords, credit card data, and more

Data size is restricted to up to 2048 chracacters only

Cannot be used to send binary data such as images, files

Less secure


Browser support

Here is when method support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like


Last updated on Sep 30, 2023

Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides