HTML formtarget Attribute
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:
- _blank: It opens the link in a new window.
- _self: It has a default value. It opens the linked document in the same frame.
- _parent: It opens the linked document in the parent frameset.
- _top: It opens the linked document in the full body of the window.
- framename: It opens the linked document in the named frame.
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 –
- Google Chrome
- Internet Explorer
- Opera
- Firefox
- Apple Safari
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...