When an HTML page contains multiple frames, as opposed to the single default frame, the form’s target attribute can be used to indicate which frame should be responsible for submission of the form’s request payload. Similarly, applying a formtarget attribute to one of the form’s submit buttons will cause the form’s submission to apply to the frame indicated by the value of the button’s formtarget attribute, effectively overriding the value specified by the form’s target attribute, if any.

Syntax:

<input type="submit" value="Submit" formtarget="_blank" />

<button formtarget="_self">Submit</button>

Elements:

The value of this attribute, if specified, should match the name attribute of a frame or iframe element, or be set to a relative frame target. Useful relative frame target values include:

  • _parent; The form window’s parent frame
  • _top; The frame which is the form’s topmost ancestor
  • _blank; A new tab or window, depending on the host browser
  • _self; Rarely used explicitly for a form’s target attribute, as this is the default form submission target, however can be useful for a submit button’s formtarget attribute to negate the parent form’s explicit target attribute value.

As an alternative, an arbitrary frame name can be specified, which will cause the form to submit into a new window or tab which will be associated with the name specified by the formtarget attribute. In such a case, subsequent form submissions will be submitted into the same window or tab as the initial submission.

Example

 

›› go to examples ››