Skip to main content

target (HTML attribute)

By Adam Roberts

HTML & CSS

Share:

Free JavaScript Book!

Write powerful, clean and maintainable JavaScript.

RRP $11.95

Description

The target attribute is deprecated and its use as a layout mechanism, like that of the frameset, is no longer common. However, if you do find yourself having to maintain a frameset-based web site, you may need to open links in frames or windows other than the one in which the source of the link resides.

Example

Here, the target attribute for the a element is set to "_top":

<p>You can try our <a href="cakes.html" target="_top">lovely range of cakes</a>.</p>

Value

The attribute can take any of the following values:

  • "_blank" loads content in a
    completely new window

  • "frame name" loads content in
    a frame with a custom name

  • "_parent" loads content in
    the parent frameset for the current
    frame

  • "_self" loads content in the same frame (This attribute isn’t normally required, as this is the default behavior unless the baseelement specifies otherwise. In that case, you’d need to override the specification using "_self"; for example, <base target="searchresults"/>.)

  • "_top" loads content in the top-level frameset (in effect, the whole browser window), no matter how many nested levels down the current frame is located

Adam is SitePoint's head of newsletters, who mainly writes Versioning, a daily newsletter covering everything new and interesting in the world of web development. He has a beard and will talk to you about beer and Star Wars, if you let him.

New books out now!

Get practical advice to start your career in programming!


Master complex transitions, transformations and animations in CSS!