target (HTML attribute)

Spec
Depr. Version
Yes HTML 2
Browser support (more…)
IE5.5+ FF1+ SA1.3+ OP9.2+ CH2+
Full Full Full Full Full

Syntax

target=" { _blank | frame name | _parent | _self | _top } "

Description

The target attribute is deprecated, and, like the use of frameset for layout purposes, it’s no longer widely used. However, if you do find yourself having to maintain a frameset-based web site, you may wish to present the results of a form submission in a separate frame. For example, you might work with a two-framed page that displays the search form in the first frame and the search results in the second frame, refreshing only the results frame each time the form is submitted.

Example

This target attribute instructs the browser to process the form in a frame with a custom name of "searchresults":
<form action="search.php" method="post" target="searchresults">
  <label for="txtsearch">Search for</label>
  <input type="text" name="txtsearch" id="txtsearch"/>
  <input type="submit" name="cmdSubmit" id="cmdSubmit" value="Search"/>
</form>

Value

Possible values for this attribute include:

  • "_blank", which sends the results to a completely new window
  • "frame-name", which sends the results to a frame with a custom name
  • "_parent", which sends the results to the current frame’s parent frameset
  • "_self", which displays the form’s submission results in the same frame1
  • "_top", which sends results to the top-level frameset (in effect, the whole browser window), no matter how many nested levels down the hierarchy the current frame is

Compatibility

Internet Explorer Firefox Safari Opera Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full

It causes no compatibility issues, and has excellent support across all tested browsers.

Footnotes

1 Note that this value isn’t normally required. The target is assumed to be the same window, unless the base element specifies the target to be a different window or frame, in which case you’d need to override the base value using "_self", like so: <base target="searchresults"/>.

User-contributed notes

Related Products