Link that opens a new window in HTML

If you want create a link to a document that opens a new browser window, set parameter target="_blank"
of the a tag.
Creating a new window is usually required if you link to another site. In other cases it is better to open documents in the current window, because too many windows may confuse the reader.
Since the links to the current and new window look identical, on some sites next to the link there is a specific icon, indicating that the document will open in a new window.
Example 1. Creating a link that opens a new window.
<a href="http://www.google.com">Usual link to the site www.google.com</a><br> <a href="http://www.google.com" target="_blank">Link opens a new window to the site www.google.com</a>
If on the web page, you want to open all the links in a new window, then there is no need to add to all the a tags parameter target="_blank"
. To reduce the code add the <base target="_blank">
, at the beginning of the page, as shown in example 2.
Example 2. Using the tag base.
<base target="_blank"> <a href="1.php">Link will open a new window</a> <a href="2.php" target="_self">Link will open in the current window</a>
To make one of the links open in the current window, add to the a tag parameter target="_self"
, as shown in the given example.