Html open link in new window
To open a link in a new window in HTML, you can use the target
attribute and set its value to _blank
. Here's 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 when the user clicks on it.
You can also use the target
attribute with other values, such as:
_self
: Opens the link in the same window or tab (default behavior)_parent
: Opens the link in the parent frame (if the link is in a frame)_top
: Opens the link in the full body of the window (if the link is in a frame)_blank
: Opens the link in a new window or tab
Note that the target
attribute only works for links that are not in a frame. If you're using a link inside a frame, you'll need to use a different approach.
Here's an example of how you can use the target
attribute with a link inside a frame:
<frameset>
<frame src="frame1.html" name="frame1">
<a rel="nofollow" target="_blank" href="https://www.example.com" target="frame1">Open in new window</a>
</frame>
</frameset>
In this example, the link will open in the same frame (frame1
) when the user clicks on it. If you want to open the link in a new window or tab, you'll need to use JavaScript to achieve this.