Href new tab
You want to know how to open a link in a new tab when using HTML's href
attribute.
To achieve this, you can add the target
attribute to the a
tag and set its value to _blank
. This will open the linked page in a new tab or window.
Here's an example:
<a rel="nofollow" target="_blank" href="https://www.example.com" target="_blank">Visit Example.com</a>
When a user clicks on the link, it will open in a new tab instead of replacing the current page.
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 tab and also prevent the parent page from being affected (e.g., not scrolling to the top), you can add rel="noopener"
to the a
tag:
<a rel="nofollow" target="_blank" href="https://www.example.com" target="_blank" rel="noopener">Visit Example.com</a>
This is useful when you want to open a link in a new tab and still allow the user to navigate back to the parent page.