This page is Not Ready

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

action

Summary

Sets the URL which the browser will send the form data on submission.

Applies to ?
The action attribute is applied to a form element in order to instruct the browser of where to send the data upon submission. If it is not specified, the browser will automatically send data back to the current address.

Best practices

It is recommended that you use an absolute URL for the action instead of a relative URL. Using an absolute URL means you know exactly where the form is going all the time, a relative URL may cause it to go to other places if you are not careful.

Mailto actions

It is possible to make an email form by placing an mailto address in the action attribute. Although it is technically possible, we recommend strongly to ‘not’ use them, as it doesn’t work in every browser as it was once supposed to. Please use an email script instead, and make the form post to that certain email script.

Examples

This example uses the action attribute to post a form to a specified URL.

<!doctype html>
<title>Contact Form Demonstration</title>

<form action="http://example.com/contact" method="post">
    <label for="email">Email: </label>
    <input id="email" name="email" type="email" required>

    <label for="name">Name:</label>
    <input id="name" name="name" required>

    <label for="message">Message: </label>
    <textarea id="message" name="message">
    </textarea>

    <button>Submit</button>
</form>

Notes

Remarks

Windows Internet Explorer 8 or later. In IE8 Standards mode, the value of the action attribute depends on the context of the reference to the attribute. When read as a Document Object Model (DOM) attribute, action returns an absolute URL. The value specified by the page author is returned when action is read as a content attribute, when the page is displayed in an earlier document compatibility mode, or when the page is viewed with an earlier version of the browser. For more information, see Attribute Differences in Internet Explorer 8. The value of the action attribute depends on the context of the reference to the attribute. When read as a DOM attribute, action returns an absolute URL. The value specified by the page author is returned when action is read as a content attribute.

Related specifications

HTML5
Candidate Recommendation

See also

Related articles

HTML

Related pages

Attributions