Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5: hyperlink and new tab

I have this hyperlink code:

<a href="http://www.youtube.com/user/mamgrow"><img style="position:relative; float:right; height:30px; left:-30px;"  alt="mamgrow facebook" src="images/facebook.png"/></a>

And I want this link to open in a new tab...

I tried to put this in:

style="target-new:tab;

But it didn't work. Any ideas?

like image 307
Ignas Damunskis Avatar asked Jan 15 '14 22:01

Ignas Damunskis


People also ask

Can I make a hyperlink open in new tab?

The first method requires a keyboard and a mouse or trackpad. Simply press and hold the Ctrl key (Cmd on a Mac) and then click the link in your browser. The link will open in a new tab in the background.

How do you create a hyperlink that opens in a new tab HTML?

You can make a HTML link open in a new tab by adding the target=”_blank” attribute. You should insert this after the link address.

Which attribute is used for open hyperlink in the new tab?

Explanation: Here, target=”_blank” is used to open a hyperlink in a new tab.

How do I make a link open in a new tab with one click?

To quickly open a link in a new tab on Google Chrome, hold down the control button while clicking on it with your mouse.


3 Answers

You can easily use the target attribute like:

<a href="http://www.example.com" target="_blank"><img src="your/image" /></a>

If your user has a browser which support tabs, the linked page will opened at a new tab in the active browser window, if set so - mostly it is a default.
Nearly every browser supports this today. See this list on Wikipedia for detailed informations.

Here a list of the target attribute properties in a <a> tag in HTML:

target="_blank" <!-- opens link in a new window -->
target="_self" <!-- opens link in actual window -->
target="_parent"
target="_top" <!-- both handle frames -->

This part of your code:

style="target-new:tab;

has no effect, its seems to be not supported by any modern browser.

like image 200
ztirom Avatar answered Oct 11 '22 01:10

ztirom


Reading the w3schools instructions explains that the syntax for opening a link in a new tab or window (depending on the settings in the web browser) you should add the attribute

target="_blank"

http://www.w3schools.com/html/html_links.asp

like image 5
Nadrendion Avatar answered Oct 11 '22 02:10

Nadrendion


You should be using the following code to open in a new window

<a href="http://www.google.com" target="_blank">...</a>
like image 3
Scott Hulme Avatar answered Oct 11 '22 01:10

Scott Hulme