Advertisement
Home Open Editor ❯

HTML <button> formtarget Attribute

Example

<form action="action.php" method="get">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <button type="submit" >Submit (default)</button>
  <button type="submit" formtarget="_blank">Submit to a new tab or window</button>
</form>

Try this code ❯

Meaning

The formtarget attribute is set to the name of a window or frame that the button action will target the result of action.

It is similar to the target attribute on <a> Element

Note: The formtarget attribute is only used for buttons with type="submit".


Standard Syntax

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


Advertisement

Attribute Values

Value Description
_self Load the response into the same tab or window.
_blank Load the response into a new tab or window.
_parant Load the response into the parent tab or window.
_top Load the response into the top-level tab or window.
frameName Load the response into the named frame
Home Open Editor ❯
Advertisement