HTML <button> formtargetAttribute

HTML <button> Tag

Examples

Two submit buttons. The first submit button uses the default target ("_self") to submit data, and the second submit button submits data to a new window (target="_blank"):

<form action="demo_form.html" method="get">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<button type="submit" >Submit</button>
<button type="submit" formtarget="_blank">Submit to a new window or tab</button>
</form>

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Internet Explorer 10, Firefox, Opera, Chrome, and Safari support the formtarget attribute.

Note:Internet Explorer 9 and earlier IE versions do not support the formtarget attribute.


Definition and Usage

The formtarget attribute specifies where to display the response after submitting the form. The formtarget attribute overrides the form element'stargetattribute.

This attribute is used with type="submit".


Differences between HTML 4.01 and HTML5

The formtarget attribute is a new attribute in HTML5.

Note:HTML5 does not support frames and framesets. Now, the parent, top, and framename values are mostly used for iframes.


Syntax

<button type="submit" formtarget="_blank|_self|_parent|_top|framename">

Attribute Values

Value Description
_blank Submits the form to a document in a new window/tab.
_self Submits the form to a document in the same frame. (Default)
_parent Submits the form to a document in the parent frame.
_top Submits the form to a document in the full window.
framename Submits the form to a document in the specified frame.


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