Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

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

  • Last Updated : 13 Jul, 2021

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 example opening a hyperlink in a new window or tab. 
 

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

html




<!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>

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. 
 

html




<!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>

Output: 
 

Explanation: Here, rel=”noopener noreferrer” is used as a security measure.
Example 3: Opening an image hyperlink in a new window or tab. 
 

html




<!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>

Output: 
 

 




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!