I know _blank
opens a new tab when used with the anchor tag and also, there are self-defined targets I use when using framesets but I will like to know the difference between _parent
, _self
and _top
.
A target="_parent" attribute value specifies that the target page will be opened in a parent frame. The target page can be a linked page or a response to a form submission.
The difference: target="_blank" is a special keyword that will open links in a new tab every time. target="blank" will open the first-clicked link in a new tab, but any future links that share target="blank" will open in that same newly-opened tab.
A target attribute with the value of “_self” opens the linked document in the same frame as it was clicked (this is the default and usually does not need to be specified). A target attribute with the value of “_parent” opens the linked document in the parent frame.
A target=\"_top\" attribute specifies that the the linked page or form response will be opened in the topmost frame. The topmost frame is the full browser tab and window.
While these answers are good, IMHO I don't think they fully address the question.
The target attribute in an anchor tag tells the browser the target of the destination of the anchor. They were initially created in order to manipulate and direct anchors to the frame system of document. This was well before CSS came to the aid of HTML developers.
While target="_self"
is default by browser and the most common target is target="_blank"
which opens the anchor in a new window(which has been redirected to tabs by browser settings usually). The "_parent"
, "_top"
and framename
tags are left a mystery to those that aren't familiar with the days of iframe site building as the trend.
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.
target="framename
This was originally deprecated but brought back in HTML5. This will target the exact frame in question. While the name
was the proper method that method has been replaced with using the id
identifying tag.
<!--Example:--> <html> <head> </head> <body> <iframe src="url1" name="A"><p> This my first iframe</p></iframe> <iframe src="url2" name="B"><p> This my second iframe</p></iframe> <iframe src="url3" name="C"><p> This my third iframe</p></iframe> <a href="url4" target="B"></a> </body> </html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With