Href link open in new tab
To make a 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">Link text</a>
This will open the link in a new tab when clicked.
Alternatively, you can use the rel
attribute and set its value to noopener
to prevent the new tab from being able to access the parent page's cookies and other information:
<a rel="nofollow" target="_blank" href="https://www.example.com" target="_blank" rel="noopener">Link text</a>
This is a good practice to use when opening links in new tabs to prevent potential security issues.
You can also use the target
attribute with other values, such as _self
to open the link in the same tab, _parent
to open the link in the parent frame, or _top
to open the link in the full body of the window.
Here's a summary of the target
attribute values:
_self
: Open the link in the same tab_blank
: Open the link in a new tab_parent
: Open the link in the parent frame_top
: Open the link in the full body of the window
Note that the target
attribute only works for links that are not already in a frame or iframe. If you're trying to open a link in a new tab from within a frame or iframe, you may need to use JavaScript to achieve this.