A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/html/html-formethod-attribute/ below:

HTML formmethod Attribute - GeeksforGeeks

HTML formmethod Attribute

Last Updated : 23 Jul, 2025

The HTML formmethod Attribute is used to define the HTTP method that is used to send form data while submitting the form. GET and POST are the two well-known HTTP methods. This attribute overrides the feature of the method attribute of the <form> element. 

Supported tags: 

Syntax:

<element formmethod="get|post">

Values:

Example 1: Below code demonstrates the use of formmethod attribute in the HTML <input type="submit"> control. Refer to the output given below for a better understanding. Notice the address bar of the new web page on clicking "Submit normally" and "submit using POST method". Both are different, one showing the user details and the latter hiding all the user details.

HTML
<!DOCTYPE html>
<html>

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

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

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

    <h3>HTML formmethod Attribute</h3>
    <form action="#"
        id="users"
        action="#"
        method="GET"
        target="_blank">

        User_id:
        <input type="email"
            name="email"
            placeholder="Enter Email Id">

        <br>
        <br> Password:
        <input type="password"
            name="pword"
            placeholder="Enter Password">
        <br>
        <br>

        <input type="submit" value="Submit normally">
      
      <input type="submit" formaction="#" 
             value="submit using POST method" 
             formmethod="post">

    </form>
</body>

</html>

Output:

Example 2: The following example demonstrates the HTML formmethod="get" attribute using the button element. It submits the user entries to the "getDetail.php" PHP file. When the user clicks "Submit using get method", the values are submitted to the PHP file, notice the address bar in the below output.

HTML
<!DOCTYPE html>
<html>

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

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

    <h3>HTML formmethod get Attribute</h3>
    <form action="getDetail.php">

        User name:
        <input name="username"
            placeholder="Enter username">

        <br>
        <br> Profession:
        <input 
            name="profession"
            placeholder="Enter profession">
        <br>
        <br>    
      
      <button formmethod="get">             
             Submit using get method 
      </button>

    </form>
</body>

</html>

Output:        

Supported Browsers:



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4