Open In App
Related Articles

HTML formtarget Attribute

Like Article
Save Article
Report issue

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”>


<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. 



<!DOCTYPE html>
        HTML formtarget Attribute
        <h1 style="color:green;">
        <h2 style="color:green;">
            HTML formtarget Attribute
        <form action="#">
            <input type="text" name="usrname">
            <input type="password" name="password">
            <input type="submit"
                value="Submit in a new window"
            <button type="submit" formtarget="_self">
                Submit with a current window



Supported Browsers:  The list of browsers supported by HTML formtarget Attribute are given below –

  • Google Chrome
  • Internet Explorer
  • Opera
  • Firefox
  • Apple Safari

Last Updated : 13 Dec, 2021
Like Article
Save Article
Share your thoughts in the comments
Similar Reads