HTML input form method Attribute

Last Updated : 31 Jul, 2026

The formmethod attribute is used to specify the HTTP method used to send form data. It overrides the method attribute of the <form> element for a specific submit button.

  • Defines the method used for form submission, such as GET or POST.
  • Works with <input type="submit"> and <input type="image">.
  • Overrides the form’s default method attribute for that submission.

Syntax

<input formmethod="get | post">

Attribute Values:

  • GET: Sends form data through the URL, making it visible in the address bar. It is suitable for non-sensitive data and supports limited data size.
  • POST: Sends form data inside the HTTP request body, so it is not visible in the URL. It supports larger data and is more secure than GET.
html
<!--Driver Code Starts-->

<!DOCTYPE html>
<html>

<head>
    <title>
        HTML input formmethod Attribute
    </title>
</head>

<body style="text-align:center;">

    <h1 style="color:green;">
      GeeksforGeeks
  </h1>

    <h3>HTML &lt;input&gt; 
      formmethod Attribute</h3>

<!--Driver Code Ends-->

    <form action="#" 
          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" 
               formmethod="post">

    </form>

<!--Driver Code Starts-->
</body>

</html>

<!--Driver Code Ends-->
Comment