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 example opening a 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" 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" 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" <img src=Geeksforgeeks_image.jpg" alt="" class="aligncenter" /> </a> </p></body></html> |
Output:



.png)
.png)