HTML action attribute

HTML action attribute: This attribute is used to define the place of form data has to be sent after filling and submitting the form. And it can be used at <form> element.

Syntax: <form action=”URL”>

HTML action attribute

Attribute Values

Let us know about the attribute values of this attribute. Attribute values are used to specify the URL of the document where the data has to sent after submission of the form.

There are two different types of  URL. They are as follows:

  • absolute URL: It will be submitting for another website link. Ex: www.freshernow.com
  • relative URL: It will be submitting a file within the web page itself. Ex: www.tutorials.freshersnow.com

Supported Browsers

This attribute will be supported by different browsers as follows:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari

Example:

<!DOCTYPE html> 
<html>   
<head> 
    <title> 
        HTML action Attribute 
    </title> 
</head>   
<body> 
    <h1>Freshersnow</h1>   
    <h2>HTML action Attribute</h2>   
    <form action="test.php" 
          method="post"
          id="users">  
        <label for="username"> 
          Username: 
      </label> 
        <input type="text"
               name="username"
               id="Username">  
        <br> 
        <br>  
        <label for="password"> 
          Paswword: 
      </label> 
        <input type="password" 
               name="password"> 
    </form>   
    <br> 
    <button onclick="myfreshersnow()"> 
        Submit 
    </button> 
    <br> 
    <br> 
    <b>After Submitting the form-data will sent 
      to the "test.php" page on the server.</b> 
</body>   
</html>

Output:

HTML action attribute