HTML method Attribute - GeeksforGeeks

19 Aug, 2021
The HTML <form> method Attribute is used to specify the HTTP method used to send data while submitting the form. There are two kinds of HTTP methods, which are GET and POST. The method attribute can be used with the <form> element. Attribute Values: 
GET: In the GET method, after the submission of the form, the form values will be visible in the address bar of the new browser tab. It has a limited size of about 3000 characters. It is only useful for non-secure data not for sensitive information.
POST: In the post method, after the submission of the form, the form values will not be visible in the address bar of the new browser tab as it was visible in the GET method. It appends form data inside the body of the HTTP request. It has no size limitation. This method does not support bookmark the result.  
Supported Tags: 
<form>
Syntax: 
<form method="get|post">
Example 1: This example illustrates the use of GET method attribute. 
html
<!DOCTYPE html><html> <head>    <title>        HTML form method Attribute    </title></head> <body style="text-align:center;">     <h1 style="color:green;">GeeksforGeeks</h1>     <h3> HTML <form> Method Attribute. </h3>         <form action="/action_page.php" id="users"                action="#" method="GET" target="_blank">                 First name: <input type="text" name="fname"                            placeholder="Enter first name">         <br><br>        Last name: <input type="text" name="lname"                            placeholder="Enter last name">        <br><br>                 <input type="submit" value="Submit">             </form>           <p>        By clicking the submit button the Entered<br>        details will be sended to "/action_page.php"    </p>  </body> </html>                   
Output:  
Example 2: This example illustrates the use of the POST method attribute. This method sends the form-data as an HTTP post-transaction. 
html
<!DOCTYPE html><html> <head>    <title>        HTML form method Attribute    </title></head> <body style="text-align:center;">     <h1 style="color:green;">GeeksforGeeks</h1>      <h3>HTML <form> Method Attribute.</h3>         <form action="/action_page.php" id="users"            action="#" method="POST" target="_blank">                 Email_id: <input type="text" name="Email_id"                    placeholder="Enter email_id">          <br><br>                 Password: <input type="password"                    placeholder="Enter Password">                 Confirm Password: <input type="password"                    placeholder="Re-enter Password">                 <br><br>                 <input type="button" value="login">      </form>           <p>        By clicking the login button the Entered<br>        details will be sended to "/action_page.php"    </p>  </body> </html>                   
Output:  
Supported Browsers:  
Google Chrome
Internet Explorer
Mozilla Firefox
Safari
Opera
 
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
arorakashish0911
hritikbhatnagar2182
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
Types of CSS (Cascading Style Sheet)
How to position a div at the bottom of its container using CSS?
HTML | <img> align Attribute
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript