HTML formaction Attribute

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

Definition and Usage

The formaction attribute sets the URL that processes the form when a specific submit control is used. It overrides the form’s action for that click only. Use it on a <button> that submits a form, or on <input type="submit"> / type="image".

One form can offer several endpoints — for example “Save draft” and “Publish” — without duplicating fields. Pair it with formmethod or formenctype when that button also needs a different method or encoding.

Baseline · Widely available.

Not deprecated and not experimental. Stable across modern browsers since about July 2015.

Needs a form owner.

Without an associated <form> (nested or via the form attribute), a submit control with formaction does nothing.

HTML Syntax

syntax.html
<button type="submit" formaction=" URL">

Same idea on inputs: <input type="submit" formaction="URL">.

Attribute Values

The value is a URL that receives the submission when that control is activated:

ValueDescriptionTry it
Absolute URLFull address, e.g. https://example.com/saveTry it
Relative URLPath relative to the page, e.g. /publish or ./draftTry it
On input type="submit"Same override behavior as on <button>Try it

Live Preview

Change the override URL on the second button, then submit. Submission is intercepted so you can see the effective endpoint.

Form default action="/default". The override button uses formaction.

Demo form

formaction="/save-draft"

HTML Examples

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

Example 1 — Two Submit Endpoints

One form, two buttons — each sends data to a different URL.

HTML
<form action="/publish" method="post">
  <label for="title">Title:</label>
  <input type="text" id="title" name="title">

  <button type="submit">Publish</button>
  <button type="submit" formaction="/save-draft">Save draft</button>
</form>
Try It Yourself

How It Works

  1. Default action. The form’s action="/publish" is used when Publish is clicked.
  2. Override on one button. Save draft sets formaction="/save-draft".
  3. Same fields. Both buttons submit the same controls; only the URL changes.
  4. Per-click override. formaction applies only for the button that was activated.

Example 2 — Relative Paths

Use site-relative paths when endpoints live on the same origin.

HTML
<form action="/articles" method="post">
  <label for="body">Body:</label>
  <textarea id="body" name="body"></textarea>

  <button type="submit" formaction="/articles/preview">Preview</button>
  <button type="submit">Save</button>
</form>
Try It Yourself

How It Works

  1. Relative URLs work. /articles/preview resolves against the current origin.
  2. Save uses the form action (/articles) because it has no formaction.
  3. Preview overrides only when that button is clicked.
  4. Same rules as action. Absolute and relative forms are both valid.

Example 3 — input type="submit"

formaction works the same on submit inputs.

HTML
<form action="/search" method="get">
  <label for="q">Query:</label>
  <input type="search" id="q" name="q">

  <input type="submit" value="Search site">
  <input type="submit" value="Search docs" formaction="/docs/search">
</form>
Try It Yourself

How It Works

  1. Same attribute on inputs. type="submit" and type="image" support formaction.
  2. Label via value. The button text comes from the value attribute.
  3. Search docs overrides the form’s /search action.
  4. Prefer <button> when you need richer content inside the control.

Edge Cases & Pitfalls

Most surprises come from missing form owners or using the wrong button type.

owner

No form owner → no submit

Nest the control in a form or set the form attribute. Alone, formaction cannot submit.

type

Only on submit controls

type="button" and type="reset" ignore formaction. Use a real submit control.

scope

Overrides only that click

Other buttons still use the form’s action. The form attribute itself is unchanged.

script

IDL name is formAction

In JavaScript, read or set element.formAction (camelCase). It reflects the attribute URL.

family

Sibling overrides exist

Also see formmethod, formenctype, formnovalidate, and formtarget.

Browser Support

formaction is an HTML attribute for submit controls in the browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

formaction

Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support overriding the form action from a submit control.

97% Global support (approx.)
Google Chrome 9+
Full support
Mozilla Firefox 4+
Full support
Apple Safari 5.1+
Full support
Microsoft Edge 12+
Full support
Opera 10.6+
Full support
Samsung Internet Modern
Full support
Internet Explorer 10+
Supported
formaction Widely supported

Bottom line: Safe to use for multi-endpoint forms in modern browsers. Always keep a sensible default action on the form.

Key Takeaways

  • Role: override the form’s action URL for one submit control.
  • Elements: submitting <button>, <input type="submit">, type="image".
  • Value: absolute or relative URL — same as action.
  • Requirement: the control must have a form owner.

One line: formaction lets each submit button pick a different endpoint without cloning the form.

Frequently Asked Questions

On a submit button or input type=submit (or image), formaction sets the URL that receives the form data. It overrides the action attribute on the owning form for that submission only.
button (when it submits a form) and input with type=submit or type=image. It has no effect on type=button or type=reset.
A URL — absolute (https://…) or relative (/save, ./draft). Same rules as the form action attribute.
No. Without a form owner (nested in a form or linked with the form attribute), a submit control with formaction does nothing useful.
action is set on the form and is the default endpoint. formaction is set on a specific submit control and overrides action when that control is used.
It is Baseline widely available (since about July 2015) in modern Chrome, Firefox, Safari, and Edge.

Next: formenctype

Override how form data is encoded when a specific button submits.

formenctype 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