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.


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

Example of the HTML action attribute:

<!DOCTYPE html>
    <title>Title of the document</title>
    <form action="/form/submit">
      <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"/>
In this example we used relative path, and the data will be sent to the /form/submit URL within the same domain as the current page. As mentioned, you can use absolute path here to address a URL from another domain, like

Practice Your Knowledge

What is the function of the HTML 'action' attribute?

Quiz Time: Test Your Skills!

Ready to challenge what you've learned? Dive into our interactive quizzes for a deeper understanding and a fun way to reinforce your knowledge.

Do you find this helpful?