HTML formtarget Attribute

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

Definition and Usage

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

Values match browsing-context names: keywords like _blank, or the name of an <iframe>. Pair with formaction when that button also needs a different URL.

Baseline · Widely available.

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

New tabs and focus.

_blank can surprise users (especially with assistive tech). Prefer same-tab submit unless a new context is clearly helpful, and label the control accordingly.

HTML Syntax

syntax.html
<button type="submit" formtarget=" browsing_context">

browsing_context is a keyword (_self, _blank, …) or a frame/iframe name.

Attribute Values

Same keywords as the form target attribute:

ValueDescriptionTry it
_selfSame browsing context (default). Replaces the current documentTry it
_blankNew unnamed tab or windowTry it
_parentParent browsing context; same as _self if noneTry it
_topTop-level browsing context; same as _self if already topTry it
Named frameMatches an <iframe name="…"> (or window name)Try it

Live Preview

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

Form default has no target (_self). The override button uses formtarget.

Demo form

formtarget="_blank"

HTML Examples

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

Example 1 — Preview in a New Tab

Keep the default submit in-page; open a preview elsewhere.

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

  <button type="submit">Save</button>
  <button
    type="submit"
    formaction="/article/preview"
    formmethod="get"
    formtarget="_blank">
    Preview in new tab
  </button>
</form>
Try It Yourself

How It Works

  1. Save uses the form’s default target (same tab).
  2. Preview sets formtarget="_blank".
  3. Optional overrides change URL and method for that button only.
  4. Label clearly so users know a new tab will open.

Example 2 — _self and _top

Useful inside frames: break out to the top window or stay local.

HTML
<form action="/settings" method="post">
  <label for="theme">Theme:</label>
  <select id="theme" name="theme">
    <option>light</option>
    <option>dark</option>
  </select>

  <button type="submit" formtarget="_self">Apply here</button>
  <button type="submit" formtarget="_top">Apply in top window</button>
</form>
Try It Yourself

How It Works

  1. _self loads the response in the current context.
  2. _top replaces the outermost page — exits nested frames.
  3. _parent goes one level up when a parent exists.
  4. Outside frames, _top and _parent behave like _self.

Example 3 — Submit Into a Named Iframe

Match formtarget to the iframe’s name.

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

  <button type="submit" formtarget="results">Show in frame</button>
</form>

<iframe name="results" title="Search results" width="100%" height="120"></iframe>
Try It Yourself

How It Works

  1. Name the iframe. name="results" defines the browsing context.
  2. Point formtarget at that exact name.
  3. Submit loads the response inside the frame, not the full page.
  4. Give the iframe a title for accessibility.

Edge Cases & Pitfalls

Most surprises involve mismatched names or unexpected new tabs.

name

Frame name must match exactly

A typo in formtarget vs iframe name opens a new window instead of the intended frame.

ux

Announce _blank

Users (and screen-reader users) need to know a new tab will open. Put that in the button text.

owner

Needs a form owner

Nest the control in a form or set the form attribute.

script

IDL name is formTarget

In JavaScript, read or set element.formTarget (camelCase).

family

Sibling overrides exist

Also see formaction, formmethod, formenctype, and formnovalidate.

Browser Support

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

✓ Baseline · Widely available

formtarget

Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support overriding the form target 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
formtarget Widely supported

Bottom line: Safe to use for per-button targets in modern browsers. Prefer same-tab submit unless a new context is intentional.

Key Takeaways

  • Role: override the form’s target for one submit control.
  • Values: _self, _blank, _parent, _top, or a frame name.
  • Iframes: match formtarget to iframe name.
  • UX: say when a new tab will open.

One line: formtarget lets each submit button choose where the response appears without cloning the form.

Frequently Asked Questions

On a submit button or input type=submit (or image), formtarget sets where the form response is displayed. It overrides the target attribute on the owning form for that submission only.
Keywords _self, _blank, _parent, and _top, or the name of a browsing context such as an iframe’s name.
target is set on the form (or links) as the default. formtarget is set on a specific submit control and overrides target when that control is used.
Usually yes — a new tab or window, depending on the browser and user settings. Pair with rel="noopener" on links; for forms, be aware of opener behavior when opening new contexts.
Yes. Give the iframe a name, then set formtarget to that same name (or use target on the form).
It is Baseline widely available (since about July 2015) in modern Chrome, Firefox, Safari, and Edge.

Next: frame

Learn the legacy frame attribute and how it relates to browsing contexts.

frame 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