Skip to: content, navigation

by Ian Lloyd

target (HTML attribute)

Browser support full matrix
IE5.5+ FF1+ Saf1.3+ Op9.2+
Full Full Full Full
Spec
Depr. Version
Yes HTML 2
target="
{ _blank | frame name | _parent | _self | _top }
"

Example

The target attribute instructing the browser 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>

Description

The target attribute is deprecated and is not used greatly nowadays, just as web sites increasingly shun use of the frameset as layout mechanisms. 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, a two-framed site that has the search form in the first frame and the results displaying in the second frame, such that only the results page gets refreshed each time.

Value

  • "_blank" - sends results to a completely new window
  • "frame-name" - sends results to a frame with a custom name
  • "_parent" - sends results to the parent frameset for the current frame
  • "_self" - displays the form’s submission results in the same frame (not normally required - assumed to be same window, unless specified in the base element as something different in which case you would need to override using "_self", e.g. <base target="searchresults” />)
  • "_top" - sends results to the absolute top level frameset (in effect, the whole browser window), no matter how many nested levels down the current frame is.

Compatibility

IE5.5Full
6.0Full
7.0Full
Firefox1.0Full
1.5Full
2.0Full
Safari1.3Full
2.0Full
3.0Full
Opera9.2Full
9.5Full

Causes no compatibility issues. It has excellent support across all tested browsers.

User-contributed notes

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters