HTML5: hyperlink and new tab

73,320

Solution 1

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.

Solution 2

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

Solution 3

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

<a href="http://www.google.com" target="_blank">...</a>
Share:
73,320

Related videos on Youtube

Ignas Damunskis
Author by

Ignas Damunskis

I'm a student of Vilnius Gediminas Technical University.

Updated on January 25, 2020

Comments

  • Ignas Damunskis
    Ignas Damunskis over 4 years

    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?

    • Chris Mukherjee
      Chris Mukherjee over 10 years
      possible duplicate of Open link in new tab
    • Sam Vloeberghs
      Sam Vloeberghs almost 9 years
      wauw: a CSS3 option with 0 browser support