HTML action Attribute


The action attribute in HTML forms specifies the URL to which the form's data is sent when the form is submitted. This attribute is essential for defining the server-side script or endpoint that will process the submitted form data. The method for sending this data is determined by the form's method attribute, which can be set to "GET" (default) or "POST".

In essence, the action attribute acts as the destination for the form data, guiding it to the correct server location for processing. If the action attribute is omitted, the form data will be sent to the same URL as the form itself. This is useful for cases where form processing and display are handled by the same URL, but specifying an action provides greater control and flexibility over form data handling.

For example, in a login form, the action attribute might be set to a URL that points to a script on the server designed to authenticate users. This script would receive the login credentials, verify them against stored data, and then respond accordingly, such as granting access to a restricted area or displaying an error message if the credentials are incorrect.

Here's a simple HTML form example demonstrating the use of the action attribute:

<form action="submit_form.php" method="POST">
    <label for="name">Name:</label>
    <input type="text" id="name" name="name">
    <label for="email">Email:</label>
    <input type="email" id="email" name="email">
    <input type="submit" value="Submit">

In this example, when the form is submitted, the data entered into the form will be sent to "submit_form.php" using the POST method. The script at "submit_form.php" will then process the form data accordingly.


<form action="URL">


  • URLA URL to a script, can be an internal or external URL. It can also be a JavaScript function.

Applies To

The action attribute can be used on the following html elements.


<form action="formscript.php" method="post">
<label for="fname">First Name:</label><br>
<input type="text" id="fname" name="firstname"><br><br>
<label for="lname">Last Name:</label><br>
<input type="text" id="lname" name="lastname"><br><br>
<input type="submit" value="Submit">

Browser Support

The following table will show you the current browser support for the HTML action Attribute.

Edge Chrome Firefox Opera Safari
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview

Last updated by CSSPortal on: 28th March 2024