HTML <form> target Attribute

Last Updated : 23 May, 2026

The target attribute in the <form> tag specifies where the response received after form submission will be displayed. It controls whether the result opens in the same tab, a new tab, or another frame.

  • Defines where the form response will be displayed.
  • Common values include _self, _blank, _parent, and _top.
  • Useful for controlling page navigation after form submission.

Syntax:

<form target="_blank">
<!-- form elements -->
</form>
  • _blank: It opens the link in a new window.
  • _self: It opens the linked document in the same frame & this is the default value.
  • _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 1: Illustrates the use of the target attribute which is set to _blank in HTML Form.

HTML
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>
<head>
    <title>HTML Form target Attribute</title>
</head>

<body>
    <h1>GeeksforGeeks</h1>
    <h2>HTML Form target Attribute</h2>
<!--Driver Code Ends-->

    <form action="#" id="GFG" target="_blank"> 
          Username:
        <input type="text" name="name">
        <br>
        Password:
        <input type="password" name="password">
        <br>
        <input type="submit" value="Submit"> 
    </form>

<!--Driver Code Starts-->
</body>
</html>
<!--Driver Code Ends-->

Example 2: Illustrates the use of target Attribute whose value is set to _self in the form element.

HTML
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>

<head>
    <title>HTML Form target Attribute</title>
    <style>
    h1 {
        color: green;
    }
    
    body {
        text-align: center;
    }
    </style>
</head>

<body>
    <h1>GeeksforGeeks</h1>
    <h2>HTML Form target Attribute</h2>
<!--Driver Code Ends-->

    <form action="#" id="GFG" target="_self"> 
        First name:
        <input type="text" name="fname">
        <br> 
        Last name:
        <input type="text" name="lname">
        <br> 
        Address:
        <input type="text" name="Address">
        <br>
        <input type="submit" value="Submit"> 
    </form>

<!--Driver Code Starts-->
</body>
</html>
<!--Driver Code Ends-->
Comment