Anchor tag open in new tab html
To open an anchor tag in a new tab, you can use the target
attribute and set its value to _blank
. Here is 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 anchor tag is clicked.
Note that you can also use target="_new"
or target="_noopener"
instead of _blank
, but _blank
is the most commonly used and supported option.
If you want to open the link in a new window instead of a new tab, you can use target="_window"
.
Here is an example of how you can use the target
attribute with other attributes:
<a rel="nofollow" target="_blank" href="https://www.example.com" target="_blank" rel="noopener noreferrer">Open in new tab</a>
The rel
attribute is used to specify the relationship between the current page and the linked page. In this case, we're using noopener
to prevent the linked page from accessing the current page's context, and noreferrer
to prevent the linked page from receiving the referrer information.