Open link in new tab or window

HtmlTabsHyperlinkWindowHref

Html Problem Overview


Is it possible to open an a href link in a new tab instead of the same tab?

<a href="http://your_url_here.html">Link</a>

Html Solutions


Solution 1 - Html

You should add the target="_blank" and rel="noopener noreferrer" in the anchor tag.

For example:

<a target="_blank" rel="noopener noreferrer" href="http://your_url_here.html">Link</a>

Adding rel="noopener noreferrer" is not mandatory, but it's a recommended security measure. More information can be found in the links below.

Source:

Solution 2 - Html

It shouldn't be your call to decide whether the link should open in a new tab or a new window, since ultimately this choice should be done by the settings of the user's browser. Some people like tabs; some like new windows.

Using _blank will tell the browser to use a new tab/window, depending on the user's browser configuration and how they click on the link (e.g. middle click, Ctrl+click, or normal click).

Solution 3 - Html

set the target attribute of your <a> element to "_tab"

EDIT: It works, however W3Schools says there is no such target attribute: http://www.w3schools.com/tags/att_a_target.asp

EDIT2: From what I've figured out from the comments. setting target to _blank will take you to a new tab or window (depending on your browser settings). Typing anything except one of the ones below will create a new tab group (I'm not sure how these work):

_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

Solution 4 - Html

You can simply do that by setting target="_blank", w3schools has an example.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionReneView Question on Stackoverflow
Solution 1 - HtmlNathanView Answer on Stackoverflow
Solution 2 - HtmlgotsonView Answer on Stackoverflow
Solution 3 - HtmlToon CasteeleView Answer on Stackoverflow
Solution 4 - HtmlEhsanView Answer on Stackoverflow