What's the difference between <a target="_new">
and <a target="_blank">
and which should I use if I just want to open a link in a new tab/window?
This question is related to
html
The target attribute of a link forces the browser to open the destination page in a new browser window. Using _blank
as a target value will spawn a new window every time while using _new
will only spawn one new window and every link clicked with a target value of _new
will replace the page loaded in the previously spawned window
target="_blank"
opens a new tab in most browsers.
Using target="_blank"
will instruct the browser to create a new browser tab or window when the user clicks on the link.
Using target="_new"
is technically invalid according to the specifications, but as far as I know every browser will behave the same way:
Note target="_new"
will behave exactly the same as target="new"
, and the latter is valid HTML while the former is invalid HTML.
Adding some confusion to this, in HTML4 the target
attribute was deprecated. In HTML5 this decision was reversed, and it is an official part of the spec once again. All browsers support target
no matter what version of HTML you are using, but some validators will flag the use as deprecated if your doctype is HTML4.
This may have been asked before but:
"every link that specifies target="_new" looks for and finds that window by name, and opens in it.
If you use target="_blank," a brand new window will be created each time, on top of the current window."
from here: http://thedesignspace.net/MT2archives/000316.html
Also, every link clicked with a target value of _new will replace the page loaded in the previously spawned window.
You can click here When to use _blank or _new to try it out for yourself.
I know this is an old question and the correct answer, use _blank
, has been mentioned several times, but using <a target="somesite.com" target="_blank">Link</a>
is a security risk.
It is recommended (performance benefits) to use:
<a href="somesite.com" target="_blank" rel="noopener noreferrer">Link</a>
Caution - remember to always include the "quotes" - at least on Chrome, target=_blank
(no quotes) is NOT THE SAME as target="_blank"
(with quotes).
The latter opens each link in a new tab/window. The former (missing quotes) opens the first link you click in one new tab/window, then overwrites that same tab/window with each subsequent link you click (that's named also with the missing quotes).
The use of _New is useful when working on pages that are Iframed. Since target="_blank" doesn't do the trick and opens the page on the same iframe... target new is the best solution for Iframe Pages. Just my five cents.
it's my understanding that target = whatever
will look for a frame/window with that name. If not found, it will open up a new window with that name. If whatever == "_new"
, it will appear just as if you used _blank
except.....
Using one of the reserved target names will bypass the "looking" phase. So, target = "_blank"
on a dozen links will open up a dozen blank windows, but target = whatever
on a dozen links will only open up one window. target = "_new"
on a dozen links may give inconstant behavior. I haven't tried it on several browsers, but should only open up one window.
At least this is how I interpret the rules.
In order to open a link in a new tab/window you'll use <a target="_blank">
.
value _blank
= targeted browsing context: a new one: tab or window depending on your browsing settings
value _new
= not valid; no such value in HTML5 for target attribute on a element
target attribute with all its values on a element: video demo
TL;DR
USE _blank
The target attribute specifies where to open the linked document.
USAGE: target="xyz" [don't forget double quotes]
_blank Opens the linked document in a new window or tab
_self Opens the linked document in the same frame as it was clicked (this is default)
_parent Opens the linked document in the parent frame
_top Opens the linked document in the full body of the window
framename Opens the linked document in a named frame
SINCE "_new" is not any of these IT WILL COME UNDER "framename" so if a user re-clicks on that hyperlink it will not open a new tab instead update the existing tab. Whereas in _blank if user clicks twice then 2 new tabs open.
Source: Stackoverflow.com