HTML <input> formaction Attribute

Last Updated : 25 May, 2026

The formaction attribute is used to specify the URL where form data will be submitted. It overrides the action attribute of the <form> element for a specific submit button.

  • Defines a custom submission URL for the form data.
  • Works with <input type="submit"> and <input type="image">.
  • Overrides the form’s default action attribute when used.

Syntax: 

<input formaction="URL"> 

Attribute Values: It contains single value URL which is used to specify the URL of the document where the data to be sent after submission of the form. The possible value of URL are:

  • absolute URL: It points to the full address of a page. For example: www.geeksforgeeks.org/data-structure
  • relative URL: It is used to point to a file within in a webpage. For Example: gfg.php
html
<!--Driver Code Starts-->

<!DOCTYPE html>
<html>

<head>
    <title>
        HTML &lt;input&gt; formAction Attribute
    </title>
</head>

<!--Driver Code Ends-->

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

    <h2> 
        HTML  &lt;input&gt; formAction Attribute 
    </h2>

    <form action="#"
          method="get"
          target="_self">
      
        <input type="text" 
               id="Geeks"
               name="myGeeks" 
               value="geeksforgeeks" 
               formTarget="_blank" 
               formMethod="post" 
               formAction="test.php">
        <input type="submit">
    </form>
</body>

<!--Driver Code Starts-->

</html>

<!--Driver Code Ends-->
Comment