Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

target="_blank" vs. target="_new"

Tags:

html

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?

like image 976
Alex Grin Avatar asked Feb 10 '11 23:02

Alex Grin


People also ask

What does it mean target _blank?

Value. Description. _blank. Opens the linked document in a new window or tab.

Is Target _blank deprecated?

It looks like target="_blank" is still alright. It is listed as a browsing context keyword in the latest HTML5 draft.

When should I use target _blank?

The most common reason to use `target=”_blank” is so that offsite links open in a separate tab. This allows a user to click on a reference and come back to it later without leaving the current page. It keeps visitors on your site longer and improves most of your metrics: bounce rate, conversion, pages visited.

Is Target _blank unsafe?

When you link to a page on another site using the target="_blank" attribute, you can expose your site to performance and security issues: The other page may run on the same process as your page.


1 Answers

Use "_blank"

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.

Security recommendation

As Daniel and Michael have pointed out in the comments, when using target _blank pointing to an untrusted website, you should, in addition, set rel="noopener". This prevents the opening site to mess with the opener via JavaScript. See this post for more information.

like image 87
fresskoma Avatar answered Sep 21 '22 19:09

fresskoma