HTML action Attribute

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The action attribute on a <form> sets the URL that processes the form submission. Use a relative path (like /search) or an absolute URL (like https://example.com/api).

Pair it with method (get or post). A submit control can override the destination with formaction. When method="dialog", action is ignored.

Baseline · Widely available.

Not deprecated and not experimental. Standard form attribute across modern browsers since about July 2015.

HTML Syntax

syntax.html
<form action=" URL"> … </form>

URL may be absolute, relative to the current page, or empty (current document).

Attribute Values

Common action value shapes:

ValueDescriptionTry it
Absolute URLFull address, e.g. https://example.com/submitTry it
Root-relative pathStarts with /, e.g. /search (same site)Try it
Empty / omittedSubmits to the current page URLTry it
Overridden by formactionSubmit button chooses a different URL for that clickTry it

Live Preview

Change action and submit. Navigation is blocked so you can read the destination safely.

Submit is prevented. The note shows where the browser would send the form.

Form

action="/search"

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Absolute Action URL

Send the form to a full address on another host (or the same site).

HTML
<form action="https://example.com/subscribe" method="post">
  <label for="email">Email:</label>
  <input type="email" id="email" name="email" required>
  <button type="submit">Subscribe</button>
</form>
Try It Yourself

How It Works

  1. action holds the URL the browser requests on submit.
  2. Absolute URLs include the scheme and host.
  3. method="post" sends fields in the body to that URL.
  4. Only on form — inputs do not use action (buttons use formaction).

Example 2 — Same-Site Relative Path

Search the current site with GET (query string on the action URL).

HTML
<form action="/search" method="get">
  <label for="q">Search:</label>
  <input type="search" id="q" name="q">
  <button type="submit">Go</button>
</form>
Try It Yourself

How It Works

  1. /search is root-relative on the same origin.
  2. method="get" appends name=value pairs after ?.
  3. Named controls (here name="q") become query parameters.
  4. Good for search and other side-effect-free reads.

Example 3 — Override with formaction

One form, two submit buttons — different destinations.

HTML
<form action="/save" method="post">
  <label for="title">Title:</label>
  <input type="text" id="title" name="title">
  <button type="submit">Save</button>
  <button type="submit" formaction="/preview">Preview</button>
</form>
Try It Yourself

How It Works

  1. Default action is /save for the form.
  2. Save uses that default.
  3. Preview sets formaction="/preview", which wins for that click.
  4. Same field data — only the destination URL changes.

Edge Cases & Pitfalls

Most issues are “wrong URL” or “wrong override,” not syntax.

dialog

Ignored with method="dialog"

In a <dialog>, that method closes the dialog without navigating — action does nothing.

override

formaction wins on that button

Check submit buttons and input type="submit|image" for a formaction that replaces the form action.

empty

Empty means current page

action="" or omitting action submits to the document URL — useful, but easy to overlook when debugging.

GET

GET puts data in the URL

Do not use GET for passwords or large payloads. Prefer method="post" for updates.

HTTPS

Prefer secure endpoints

Submit sensitive forms to https:// URLs so credentials and data are not sent in clear text.

Browser Support

action is an HTML form attribute in the browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

action

Widely available since about July 2015. Supported everywhere forms are supported.

99% Form attribute support
Google Chrome All modern
Full support
Mozilla Firefox All modern
Full support
Apple Safari All modern
Full support
Microsoft Edge All modern
Full support
Opera All modern
Full support
Samsung Internet All modern
Full support
Internet Explorer All versions with forms
Supported
action Widely supported

Bottom line: Safe to use in every modern browser. Remember: formaction can override it, and method="dialog" ignores it.

Key Takeaways

  • Role: URL that receives the submitted form.
  • Values: absolute URL, relative path, or empty (current page).
  • Overrides: formaction on a submit control replaces action.
  • With method: GET appends a query string; POST uses the request body.

One line: action is where the form goes — unless a button’s formaction says otherwise.

Frequently Asked Questions

On a form, action sets the URL that processes the submitted data. Relative paths resolve against the current page; absolute URLs point to a full address.
The form typically submits to the current page URL. An empty action="" also means the current document URL.
Yes. A submit control can set formaction, which overrides the form’s action for that click.
When method="dialog" is set, the form closes a dialog instead of navigating, so action is ignored.
With method="get" (default), field data is appended to the action URL as a query string. With method="post", data goes in the request body to that URL.
No. It is a standard form attribute and Baseline widely available.

Next: align

Legacy alignment attribute — prefer CSS today.

align tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful