9

What target="_parent | _top" does in anchor tag?

<a href="somepage.html" target="_parent">link</a>

I didn't find any example for it. It would be great if someone could give real example of this attribute. I've checked various resources including stackoverflow

Are these attribute values deprecated, if not how could we use them now? I'm confused because articles regarding these attribute value only say what it does. but don't give example.

Community
  • 1
  • 1
Ashish
  • 313
  • 1
  • 5
  • 14
  • 1
    Possible duplicate of [target="\_blank" vs. target="\_new"](http://stackoverflow.com/questions/4964130/target-blank-vs-target-new) – michele b May 10 '16 at 08:00

3 Answers3

8

target="_self" This opens an anchor in the same frame. What is confusing is that because we generally don't write in frames anymore (and the frame and frameset tags are obsolete in HTML5) people assume this a same window function. Instead if this anchor was nested in frames it would open in a sandbox mode of sorts, meaning only in that frame.

target="_parent" Will open the in the next level up of a frame if they were nested to inside one another

target="_top" This breaks outside of all the frames it is nested in and opens the link as top document in the browser window.

Obadah Hammoud
  • 572
  • 2
  • 13
2

taget="_parent" is used in the situation where a frameset file is nested inside another frameset file. A link in one of the inner frameset documents which uses "_parent" will load the new document where the inner frameset file had been.

Check this example :http://www.tagindex.net/html/frame/example_t03.html

target="_top" is used in the situation where the linked page opens in the entire new window

Check this example for top : http://www.tagindex.net/html/frame/example_t01.html

Mukesh Ram
  • 6,248
  • 4
  • 19
  • 37
  • Hmm .. that make sense now. Great thanks. So what I got is if we apply target = "_parent" to anchor link on the page( that is loaded into frame of another (parent) page ), by clicking the link the content is loaded to parent of the current page. – Ashish May 10 '16 at 08:28
1

_parent was used when a common way to create websites was to create a framespace with frames inside, for example:

<html>
  <frameset framespacing="0" rows="50%, 50%">
    <frame frameborder="0" src="red.html" scrolling="no" noresize="1" />
    <frame frameborder="0" src="blue.html"                             />
  </frameset>
</html>

in this case a link inside the blue.html will open the target inside the frame, using target _parent the page will be opened in the parent container and not in the blue.html box

_top is similar but the link is opened ever in the main window. example: http://www.w3schools.com/html/tryit.asp?filename=tryhtml_links_target_top

danilonet
  • 1,757
  • 16
  • 33