Html code open in new window
To open an HTML link in a new window, 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 browser window 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 (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 (as shown above)
Here's an example of using the target
attribute with other values:
<a rel="nofollow" target="_blank" href="https://www.example.com" target="_self">Open in same window</a>
<a rel="nofollow" target="_blank" href="https://www.example.com" target="_parent">Open in parent frame</a>
<a rel="nofollow" target="_blank" href="https://www.example.com" target="_top">Open in full window</a>
Note that the target
attribute only works for links that are not in a form. If you're trying to open a form in a new window, you'll need to use JavaScript to achieve this.