The target attribute of the <form> element allows you to display the response generated after submitting the form.
Following is the syntax −
<form target="_blank|_self|_parent|_top|frame">
Here, _blank is used to display the response in new window or tab, _self display the response in the same frame, _parent displays the response in the parent frame, _top displays the response in the entire body of the window, frame displays the response in a named frame.
Let us now see an example to implement the target attribute of the <form> element −
Example
<!DOCTYPE html> <html> <body> <h2>Points</h2> <form action="new.php" method="get" target="_blank"> Player: <input type="text" name="player"><br> Rank: <input type="number" name="rank"><br> Points: <input type="number" name="points"><br> <button type="submit" value="Submit">Submit</button> </form> </body> </html>
This will produce the following output. When you will submit the form, the response would appear in a new window −
On form submission, the following response would be displayed in a new window −