Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

What is formmethod Attribute in HTML Form ?

  • Last Updated : 06 Sep, 2021

What is formmethod Attribute?

The formmethod attribute in HTML is used to define a HTTP technique that specify how to send form-data to the backend server.  This attribute is apply on <button> , <input type= “submit”> and <input type=”image”>. It overrides the feature of method attribute of the <form> element. 

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

How to send data?

The data can be sent to the server by using the URL variables by using the GET method and as an HTTP post by using the POST method. 



 

What is GET and POST Method?

  • GET Method: 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 but not for sensitive information. It supports Bookmarking the result. It can’t be used to send binary data.
  • POST Method: 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 bookmarking of the result.

Example: 

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>
        What is formmethod Attribute in HTML?
    </title>
  
    <style>
        h3 h2 {
            font-family: impact;
        }
    </style>
</head>
  
<body style="text-align: center;">
    <h1 style="color: green;">
        GeeksforGeeks
    </h1>
  
    <h3>What is formmethod Attribute in HTML?</h3>
      
    <form action="#" id="users" action="#" 
        method="GET" target="_blank">
  
        User_id:
        <input type="email" name="email" 
            placeholder="Emter Email Id" />
        <br /><br />
  
        Password:
        <input type="password" name="pword" 
            placeholder="Enter Password" />
        <br /><br />
  
        <input type="submit" 
            value="Submit using GET method" 
            formmethod="get" />
  
        <input type="submit" formaction="#" 
            value="submit using POST method" 
            formmethod="post" />
    </form>
</body>
  
</html>

Output:

Submit form using POST Method:

Submit form using GET Method:




My Personal Notes arrow_drop_up
Recommended Articles
Page :