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="/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"/>
</form>
</body>
</html>
/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 https://example.com/some-page
.