HTML <form> targetAttribute

HTML form 标签参考手册HTML <form> Tag

Examples

Submit a form that opens in a new window or new tab, i.e., display the received response in a new window or new tab:

<form action="demo_form.html" method="get" target="_blank">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
<input type="submit" value="提交">
</form>

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the target attribute.


Definition and Usage

The target attribute specifies a name or a keyword that indicates where to open the action URL, i.e., where to display the response received after submitting the form.

The target attribute defines the name or keyword of the browser context (such as a tab, window, or inline frame).


Differences between HTML 4.01 and HTML5

HTML5 supports the target attribute.

In HTML 4.01, the target attributeis deprecated。

Note:In HTML5, frame and frameset are no longer supported, so _parent, _top, andframenamevalues are mostly used for iframe.


Syntax

<form target="_blank|_self|_parent|_top|framename">

Attribute Values

Value Description
_blank Opens in a new window/tab.
_self Opens in the same frame. (Default)
_parent Opens in the parent frame.
_top Opens in the entire window.
framename Opens in the specified iframe.


HTML form 标签参考手册HTML <form> Tag Other Extensions