HTML <button> with formtarget Attribute

You are Here:

HTML <button> with formtarget Attribute

The formtarget attribute specifies where to display the response after submitting the form.

_blank

Load the response into a new window, when a form is submitted.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <form action="/user-name.php" method="get"> Name: <input type="text" name="name"> <button type="submit" formtarget="_blank">Submit</button> </form> </body> </html>

Attribute Value

ValueExplanation
_blankLoad the response into a new window, when a form is submitted.
_selfLoad the response into the same frame, when a form is submitted.
_parentLoad the response into the parent frame (one frame above the actual frame), when a form is submitted.
_topLoad the response into the top most frame (whole window of the same page), when a form is submitted.

_self

Load the response into the same frame, when a form is submitted.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <form action="/user-name.php" method="get"> Name: <input type="text" name="name"> <button type="submit" formtarget="_self">Submit</button> </form> </body> </html>

_parent

Load the response into the parent frame (one frame above the actual frame), when a form is submitted.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <form action="/user-name.php" method="get"> Name: <input type="text" name="name"> <button type="submit" formtarget="_parent">Submit</button> </form> </body> </html>

_top

Load the response into the top most frame (whole window of the same page), when a form is submitted.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <form action="/user-name.php" method="get"> Name: <input type="text" name="name"> <button type="submit" formtarget="_top">Submit</button> </form> </body> </html>

Reminder

Hi Developers, we almost covered 99.5% of HTML Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in HTML.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author