Last Updated : 13 Dec, 2021
The HTML formTarget Attribute is used to specify the name or a keyword, that indicates where to display a result after submitting the form. It specify that the submitted result will be open in current window, a new tab or a new frame. This attribute overrides the feature of target attribute of <form> element.
Uses: It is used in <button> and <input type="submit"> and <input type="image">
Syntax:
<element formtarget="_blank|_self|_parent|_top|framename">
Attribute Values:
Example: This example illustrates a form that contains two submit buttons, one will submit in a current frame and another button submit in a new frame.
HTML
<!DOCTYPE html>
<html>
<head>
<title>
HTML formtarget Attribute
</title>
</head>
<body>
<center>
<h1 style="color:green;">
GeeksforGeeks
</h1>
<h2 style="color:green;">
HTML formtarget Attribute
</h2>
<form action="#">
Username:
<input type="text" name="usrname">
<br><br>
Password:
<input type="password" name="password">
<br><br>
<input type="submit"
value="Submit in a new window"
formtarget="_blank">
<button type="submit" formtarget="_self">
Submit with a current window
</button>
</form>
</center>
</body>
</html>
Output
Supported Browsers: The list of browsers supported by HTML formtarget Attribute are given below -
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4