To open a link (a href) in a new browser window you need to add one more attribute to your HTML anchor element (<a>
) namely, the target
attribute.
Just like the href
attribute needs a link path value (the URL), the target
attribute needs a specific value to trigger the browser to open a new tab when you click on the link. This value is called _blank
.
Open link in new tab example:
Here's a link that goes to the techstacker front page via a new tab:
HTML code for the example:
<a href="https://techstacker.com" target="_blank" rel="noopener">Go to Techstacker.com</a>
As simple as that, happy linking!