HTML Attributes
HTML action Attribute
The action attribute defines the URL that processes a form's data when it is submitted.
The action Attribute
The action attribute belongs to the <form> element. It holds the URL of the server-side program or endpoint that receives and processes the form data when the user submits the form. It works together with the method attribute, which decides whether the data is sent as a GET or POST request.
Syntax
Syntax: <form action="url" method="post">. The value is any valid URL, absolute or relative. If omitted, the form submits to the current page URL.
<form action="/api/apply" method="post">
<input type="email" name="email" required>
<button type="submit">Submit application</button>
</form>| Value | Description |
|---|---|
| /apply | A relative URL on the same site |
| https://example.com/apply | An absolute URL to any server |
| (empty) | Submits to the current page URL |
| mailto:you@example.com | Opens an email client (not recommended for real forms) |
You can override a form's action per submit button using the formaction attribute on <button> or <input type="submit">, which is handy when one form has multiple submit targets.
