HTML action Attribute

The HTML "action" attribute specifies where the form-data should be sent when the form is submitted. Its attribute value (URL) determines where the data must be sent after the form submission. The URL can have the following values:

  • absolute URL, which refers to another website link.
  • relative URL, which refers to a file within a webpage.

You can use this attribute only on the <form> element.

SyntaxΒΆ

<form action="URL"></form>

Example of the HTML "action" attribute:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <form action="url">
      <label for="fname">Name</label>
      <input type="text" name="FirstName" id="fname" value="Mary"/><br/><br/>
      <label for="lname">Surname</label>
      <input type="text" name="LastName"id="lname" value="Thomson"/><br/><br/>
      <input type="submit" value="Submit"/>
    </form>
  </body>
</html>



Do you find this helpful?

Related articles