A href open in a 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">Open in new tab</a>
This will open the link in a new tab 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 able to access the parent page's cookies and other information. Here's an example:
<a rel="nofollow" target="_blank" href="https://www.example.com" target="_blank" rel="noopener">Open in new tab</a>
Note that the noopener
value is supported in most modern browsers, but the noreferrer
value is not supported in Internet Explorer.
You can also use the target
attribute with other values, such as _self
to open the link in the same tab, _parent
to open the link in the parent frame, or _top
to open the link in the full body of the window. However, _blank
is the most commonly used value for opening a link in a new tab.