HTML <button> formtarget attribute
Definition and Usage
formtarget
specifies where the response is displayed after the form is submitted. This attribute overrides the form's The target attribute。
formtarget
The attribute is used only for type="submit"
of the buttons.
Example
A form with two submit buttons. The first submit button submits the form data using the default target ("_self"), and the second submit button submits the form data to a new window (target="_blank"):
<form action="/action_page.php" method="get"> <label for="fname">Name:</label> <input type="text" id="fname" name="fname"><br><br> <label for="lname">Surname:</label> <input type="text" id="lname" name="lname"><br><br> <button type="submit">Submit</button> <button type="submit" formtarget="_blank">Submit to New Window</button> </form>
Syntax
<button type="submit" formtarget="_blank|_self|_parent|_top|framename">
Attribute Value
Value | Description |
---|---|
_blank | Load the response in a new window/tab. |
_self | Load the response in the same frame (default). |
_parent | Load the response in the parent frame. |
_top | Load the response in the entire window. |
framename | Load the response in the named iframe. |
Browser Support
The numbers in the table indicate the first browser version to fully support this attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
9.0 | 10.0 | 4.0 | 5.1 | 10.6 |