A tag open in new tab
You want to know how to open a tag in a new tab when clicked, right?
To achieve this, you can use the target
attribute in your HTML tag. Here's an example:
<a rel="nofollow" target="_blank" href="https://www.example.com" target="_blank">Open in new tab</a>
The _blank
value tells the browser to open the link in a new tab or window.
Alternatively, you can use JavaScript to achieve this. Here's an example:
<a rel="nofollow" target="_blank" href="https://www.example.com" onclick="window.open(this.href, '_blank'); return false;">Open in new tab</a>
In this example, the onclick
event is triggered when the link is clicked. The window.open
function is used to open the link in a new tab, and the return false
statement prevents the default link behavior from occurring.
Note that the target
attribute is supported in most modern browsers, but the JavaScript approach is more flexible and can be used in older browsers as well.