Skip to: content, navigation

by Ian Lloyd

action (HTML attribute)

Browser support full matrix
IE5.5+ FF1+ Saf1.3+ Op9.2+
Full Full Full Full
Spec
Depr. Version
No HTML 2
action="url"

Example

The action attribute here tells the browser to send the form data to a form-handling PHP page (which will presumably convert the form data to something 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>

Description

A form is useless without having some kind of processing 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.

Value

A URL, which may be in the same directory on the server, another directory on the server (for example a shared CGI folder that has various form-processing scripts) or even a page/script on an entirely separate server (perhaps a free form-handling service, if you do not have the facilities or necessary scripting skills to process form data for yourself).

Compatibility

IE5.5Full
6.0Full
7.0Full
Firefox1.0Full
1.5Full
2.0Full
Safari1.3Full
2.0Full
3.0Full
Opera9.2Full
9.5Full

Causes no compatibility issues. It has excellent support across all tested browsers.

In addition to specifying a URL, some browsers will allow understand a mailto URL which will then open the email client on the computer and generate a new message which can then be sent by the user, but this is not a particularly slick way of managing form data - you are much better off using server-side processing to ensure a consistent behavior across browsers.

User-contributed notes

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters