Href target new tab
A common request!
To open a link in a new tab when the user clicks on it, 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">Open in new tab</a>
This will open the link in a new tab when the user clicks on it.
Note that you can also use target="_new"
or target="_noopener"
instead of _blank
, but _blank
is the most widely supported option.
If you want to open the link in a new tab and also prevent the parent page from following the link, you can add the rel
attribute and set its value to noopener
. Here's an example:
<a rel="nofollow" target="_blank" href="https://www.example.com" target="_blank" rel="noopener">Open in new tab</a>
This will open the link in a new tab and prevent the parent page from following the link, which can help prevent issues with page navigation and security.