action (HTML attribute)

Spec
Depr. Version
No HTML 2
Browser support (more…)
IE5.5+ FF1+ SA1.3+ OP9.2+ CH2+
Full Full Full Full Full

Syntax

action="uri"

Description

A form is useless unless some kind of processing takes place after the form is submitted. The action attribute is used to inform the browser what page (or script) to call once the "submit" button is pressed.

Example

Here, the action attribute tells the browser to send the form data to a form-handling PHP page (which will presumably convert the form data to something more email-friendly):
<form action="form-to-email.php" method="post"
    accept-charset="windows-1252">
  <div>
    <label for="txtname">Name:</label>
    <input type="text" name="txtname" id="txtname"/>
  </div>
 ⋮
</form>

Value

This element takes as its value a URL to a document that may be on the same server (for example, a shared CGI folder that has various form-processing scripts), or even a page or script on an entirely separate server (perhaps a free form-handling service).

Compatibility

Internet Explorer Firefox Safari Opera Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full

It causes no compatibility issues, and has excellent support across all tested browsers.

In addition to allowing a URL value, some browsers will understand a mailto: URL, which will open the email client on the user’s computer and generate a new message, but this isn’t a particularly slick way of managing form data. It’s a much better approach to use server-side processing to ensure consistent behavior across browsers.

User-contributed notes

Related Products