target="_blank" vs. target="_new"
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?
According to the HTML5 Spec:
A valid browsing context name is any string with at least one character that does not start with a U+005F LOW LINE character. (Names starting with an underscore are reserved for special keywords.)
A valid browsing context name or keyword is any string that is either a valid browsing context name or that is an ASCII case-insensitive match for one of: _blank, _self, _parent, or _top." - Source
That means that there is no such keyword as
_new in HTML5, and not in HTML4 (and consequently XHTML) either. That means, that there will be no consistent behavior whatsoever if you use this as a value for the target attribute.
As Daniel and Michael have pointed out in the comments, when using target
_blank pointing to an untrusted website, you should, in addition, set
Read more... Read less...
target="_blank" will instruct the browser to create a new browser tab or window when the user clicks on the link.
target="_new" is technically invalid according to the specifications, but as far as I know every browser will behave the same way:
- it will search for a tab or window with the context name "_new"
- if a "_new" tab/window is found, then the URL is loaded into it
- if it's not found, a new tab/window is created with the context name "_new", and the URL loaded into it
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.
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.
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.
<a href="somesite.com" target="_blank" rel="noopener noreferrer">Link</a>
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."
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
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.