Use the form target="_blank" attribute when the submitted response should open in a new browsing context. In most browsers this is a new tab, although the browser or user settings ultimately decide whether it appears as a tab or window.
<form action="test5.php" method="post" target="_blank">
<label for="name">Name</label>
<input type="text" id="name" name="name">
<button type="submit">Submit in new tab</button>
</form>
The form data is sent to test5.php, while the current page remains open. This can be useful for reports, previews, generated graphs, or other results that users may want to inspect without leaving the form.
This demo submits the value to the original test5.php processing page and asks the browser to show the response in a new tab or window.
When every submission from a form should open separately, put target="_blank" on the <form> element.
<form action="test5.php" method="post" target="_blank">
<input type="text" name="name" value="plus2net">
<button type="submit">Open result</button>
</form>
If the form normally submits in the current tab but one submit button should open the response separately, use formtarget="_blank" on that button. This avoids changing the form with JavaScript.
<form action="test5.php" method="post">
<button type="submit">Submit here</button>
<button type="submit" formtarget="_blank">Open separately</button>
</form>
For multiple buttons that submit to different action pages, see submitting one form to different pages.
A named target can reuse the same secondary browsing context for later submissions instead of requesting a new one each time.
<form action="test5.php" method="post" target="reportWindow">
...
</form>
This can be useful for repeated previews or reports. Do not rely on a specific window size or position; browsers control how browsing contexts are presented.
Not for the basic case. The original page changed this.form.target inside an onclick handler. Native target or formtarget is simpler and keeps submission behavior in the form markup.
JavaScript is useful only when the destination or workflow genuinely depends on application logic that HTML attributes cannot express cleanly.
The target does not determine whether a form uses GET or POST. Choose the method according to what the request does:
Opening a new tab or window changes the user's browsing context, so use it only when it provides a clear benefit. Button text should make the behavior understandable, such as “Open report in new tab.” Keep form controls properly labeled, and do not use a new tab merely to prevent users from leaving a page.
For routine form completion, submitting in the same tab is usually simpler. New browsing contexts are most useful when users need to compare or repeatedly generate results while keeping the original form available.
For standard cases, use target or formtarget. They are clearer and work without JavaScript.
_blank requests a new browsing context. The browser may present it as a tab or a window.
Unexpected context changes can confuse users. Use the pattern only when keeping the original page open has a practical purpose.
The destination page must validate and process submitted values safely regardless of where the result opens.
Add target="_blank" to the form when every submission should open separately.
Yes. Put formtarget="_blank" on that submit button while leaving the form's normal target unchanged.
No. The native target and formtarget attributes cover the common cases.
No. It opens a new browsing context, which the browser may display as a tab or a window.
Yes. The form can use method="post" together with target="_blank".
No. POST does not encrypt the data. Use HTTPS for sensitive information and validate all submitted values on the server.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.
| Mohamed Osama | 25-11-2015 |
| Thanks it's works fine with me :) to open new tab after submit | |
| amlan roy | 22-08-2016 |
| Thank u soo much .. | |
29-03-2021 | |
| Finally, my problem was solved. | |
28-01-2023 | |
| You can also put `target="_blank"` in the form tag. <form action=.. target="_blank"> This doesn't use any javascript. | |