A href open in new tab
To make a link open in a new tab, you can add the target
attribute to the a
tag and set its value to _blank
. Here's an example:
<a rel="nofollow" target="_blank" href="https://www.example.com" target="_blank">Link to example.com</a>
This will open the link in a new tab or window when clicked.
Alternatively, you can also use the rel
attribute and set its value to noopener
or noreferrer
to prevent the new tab from being considered as a referrer for the linked page, and to prevent the linked page from accessing the parent page's context:
<a rel="nofollow" target="_blank" href="https://www.example.com" target="_blank" rel="noopener noreferrer">Link to example.com</a>
Note that the noopener
and noreferrer
values are not supported in older browsers, so you may want to use the target="_blank"
approach instead if you need to support older browsers.