The HTML formtarget attribute
Quick answer
The HTML formtarget attribute overrides the form's target for this button's submission. It is used on the <button> and <input type="submit"> elements.
Overview
The formtarget attribute overrides the form target for one button. It is used on <button> and submit-type <input> controls.
It applies to buttons. Several of these let a single submit button override the parent <form>'s settings (its action, method, encoding or validation), while others wire a button to a popover or a built-in command.
Syntax
<button formtarget="_blank">Open result in new tab</button>
Values
| Value |
|---|
| _self | _blank | _parent | _top | a named context |
Best practices
- Always set an explicit type on a <button> — the default inside a form is
submit. - Use the
form*override attributes only when one button genuinely needs different submission behavior. - Give every button clear, descriptive text for screen readers.
- Prefer real <button> elements over clickable <div>s for keyboard and accessibility support.
Frequently asked questions
What does the formtarget attribute do?
Overrides the form target for one button.
Why does my button submit the form unexpectedly?
Can one button submit to a different URL than the form?
Yes. Put
formaction (and optionally formmethod) on that submit button to override the form.