Html code to open link in new window
To open a link in a new window, you can use the target
attribute in the a
tag and set its value to _blank
. Here is an example:
<a rel="nofollow" target="_blank" href="https://www.example.com" target="_blank">Open in new window</a>
This will open the link in a new window or tab, depending on the user's browser settings.
You can also use the rel
attribute to specify that the link should be opened in a new window. For example:
<a rel="nofollow" target="_blank" href="https://www.example.com" rel="noopener noreferrer" target="_blank">Open in new window</a>
The rel
attribute is optional, but it's a good practice to include it to ensure that the link is opened in a new window and not in the same window.
Note that some browsers may not support the target
attribute or may have different behavior when opening links in new windows. It's always a good idea to test your links in different browsers to ensure that they work as expected.