HTML <input> with formtarget Attribute

HTML <input> with formtarget Attribute

The formtarget attribute specifies where to display the response that is received 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> <p>Choose any number</p> <form action="/user-number.php"> <input type="number" name="myNumber"> <input type="submit" formtarget="_blank"> </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> <p>Choose any number</p> <form action="/user-number.php"> <input type="number" name="myNumber"> <input type="submit" formtarget="_self"> </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> <p>Choose any number</p> <form action="/user-number.php"> <input type="number" name="myNumber"> <input type="submit" formtarget="_parent"> </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> <p>Choose any number</p> <form action="/user-number.php"> <input type="number" name="myNumber"> <input type="submit" formtarget="_top"> </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.

Meet the Author