The formtarget attribute is used to specify where the response should be displayed after submitting a form. It overrides the target attribute of the <form> element for a specific submit button.
- Defines where the submitted form response will open.
- Works with <input type="submit"> and <input type="image">.
- Overrides the form’s default target attribute for that submission.
Syntax:
<input formtarget="_blank|_self|_parent|_top|framename">Attribute Values:
- _blank: The input response is display in a new window.
- _self: The input response is display in the same frame. it is the default value.
- _parent: The input response is display in the parent frameset.
- _top: The input response is display in the full body of the window.
- framename: The input response is display in the named frame.
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>
<head>
<title>
HTML input formtarget Attribute
</title>
</head>
<!--Driver Code Ends-->
<body>
<center>
<h1 style="color:green;">
GeeksforGeeks
</h1>
<h2>
HTML <input> formtarget Attribute
</h2>
<form action="#">
Username:
<input type="text" name="username">
<br><br>
Password:
<input type="text" name="password">
<br><br>
<input type="submit" value="Submit" formtarget="_blank">
</form>
</center>
</body>
<!--Driver Code Starts-->
</html>
<!--Driver Code Ends-->