Html a open in new tab
To make an HTML 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 or window when the user clicks on it.
You can also use the rel
attribute to specify that the link should be opened in a new tab. The value noopener
is recommended to prevent the new tab from accessing the parent page's cookies and other data:
<a rel="nofollow" target="_blank" href="https://www.example.com" rel="noopener noreferrer" target="_blank">Open in new tab</a>
Note that the noopener
value is not supported in older browsers, so you may want to use the target
attribute alone if you need to support older browsers.
It's also a good practice to add the title
attribute to the a
tag to provide a tooltip or hover text that indicates that the link will open in a new tab:
<a rel="nofollow" target="_blank" href="https://www.example.com" target="_blank" title="Open in new tab">Open in new tab</a>
This way, users will know what to expect when they click on the link.