A href code new tab
To open a link in a new tab using HTML, you can use the target
attribute and set its value to _blank
. Here's the syntax:
<a rel="nofollow" target="_blank" href="https://www.example.com" target="_blank">Link Text</a>
This will open the link in a new tab or window, depending on the user's browser settings.
If you want to open the link in a new tab and also specify the title of the tab, you can use the target
attribute and set its value to _blank
, and also add the title
attribute to specify the title of the tab:
<a rel="nofollow" target="_blank" href="https://www.example.com" target="_blank" title="New Tab">Link Text</a>
Note that the title
attribute is not supported in all browsers, so it's not a reliable way to specify the title of the tab.
You can also use the rel
attribute to specify that the link should be opened in a new tab. The value of the rel
attribute should be noopener
or noreferrer
to prevent the new tab from being able to access the parent page:
<a rel="nofollow" target="_blank" href="https://www.example.com" rel="noopener noreferrer" target="_blank">Link Text</a>
This is a good practice to prevent potential security issues and to improve the user experience.
It's also worth noting that you can use JavaScript to open a link in a new tab. For example:
<a rel="nofollow" target="_blank" href="https://www.example.com" onclick="window.open(this.href, '_blank'); return false;">Link Text</a>
This will open the link in a new tab when the user clicks on it. The onclick
event is triggered when the user clicks on the link, and the window.open
function is used to open the link in a new tab. The return false
statement is used to prevent the default behavior of the link (i.e., following the link in the same tab).