How to open a hyperlink in another window or tab in HTML ?

There are various methods of opening a hyperlink in another window or tab such as using javaScript, jQuery or HTML. For opening a hyperlink in another window or tab using HTML, use target attribute and provide it value _blank in the anchor tab.

Syntax:

<a target="target_name" rel="relation_name" href="link">Link Name</a>

Here, rel attribute is used to describe the relation between current document and linked document and target attribute is used to specify the target link.

Example 1: This eample opening a hyperlink in a new window or tab.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        Open hyperlink in a
        new window or tab
    </title>
</head>
  
<body>
    <p>A computer science portal for geeks
        <a target="_blank" 
            href="https://www.geeksforgeeks.org/">
            GeeksforGeeks
        </a>
    </p>
</body>
  
</html>

chevron_right


Output:



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

Example 2: Opening a hyperlink in a new window or tab using security measure.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        Open hyperlink in a
        new window or tab
    </title>
</head>
  
<body>
    <p>A computer science portal for geeks
        <a target="_blank" rel="noopener noreferrer"
            href="https://www.geeksforgeeks.org/">
            GeeksforGeeks
        </a>
    </p>
</body>
  
</html>

chevron_right


Output:

Explanation: Here, rel=”noopener noreferrer” is used as a security measure.

Example 3: Opening an image hyperlink in a new window or tab.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        Open hyperlink in a
        new window or tab
    </title>
</head>
  
<body>
    <p>A computer science portal for geeks
        <a target="_blank" rel="noopener noreferrer"
                href="https://www.geeksforgeeks.org/">
                  
            <img src=Geeksforgeeks_image.jpg" alt=""
                    class="aligncenter" />
        </a>
    </p>
</body>
  
</html>

chevron_right


Output:

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.