HTML PushButton formTarget Property: Specifying the Target Window or Frame

The HTML formTarget property allows you to override the target attribute of a form for a specific <button> element. This property defines where the form’s response will be displayed after the form is submitted. It provides control over whether the response opens in a new tab, the same frame, a parent frame, or the full window.

What is the formTarget Property?

The formTarget attribute for the <button> element is used to specify the browsing context (e.g., tab, window, or iframe) where the form’s response will be displayed. It offers a way to control the navigation behavior upon form submission, differing from the form’s default target attribute.

Purpose of the formTarget Property

The primary purpose of the formTarget property is to:

  • Override the form’s target attribute for a specific button.
  • Specify where the form’s response should be displayed.
  • Control navigation behavior upon form submission.

Syntax

The formTarget attribute can be used within the <button> element as follows:

<button type="submit" formTarget="value">Submit</button>

Possible Values for formTarget

Value Description
`_self` Loads the response in the same browsing context as the current one. This is the default behavior if `formTarget` is not specified.
`_blank` Loads the response into a new, unnamed browsing context (usually a new tab or window).
`_parent` Loads the response into the parent browsing context of the current one. This is useful within iframes.
`_top` Loads the response into the topmost browsing context (i.e., the full window), effectively breaking out of any frames.
`framename` Loads the response into a specific `