Hyperlinks are used to jump from one page to another. A hyperlink commonly opens in the same page by default. But it is possible to open hyperlinks in a separate window.
Opening external links in a new tab or window will make people leave your website. In this way, you prevent your visitors from returning to your website. Remember that visitors can open a new tab themselves and are irritated when a link opens in a new tab or window without their consent. That’s why it’s recommended to avoid opening links in a new tab or window. However, there can be specific situations when this is needed, and in this snippet, we’ll demonstrate how it can be done.
As you know, in HTML the <a> tag is used with the href attribute for creating hyperlinks.
When it is needed to tell the browser where to open the document, the target attribute is used.
<!DOCTYPE html>
<html>
<head>
<title>How to Open Hyperlink in a New Window</title>
</head>
<body>
<p>
<a href="http://blog-it.tn/" target="_blank">Link</a>
</p>
</body>
</html>