Home / Articles / Programming languages / Markup languages / HTML & CSS / Link that opens a new window in HTML

Link that opens a new window in HTML

Link that opens a new window in HTML
 
Link that opens a new window in HTML
  • Currently 0 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Rating: 0/5 (0 votes cast)

Thank you for rating!

You have already rated this page, you can only rate it once!

Your rating has been changed, thanks for rating!

Log in or create a user account to rate this page.


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.


 

Read also

How to create a link in HTML

How to create a link in HTML

Parameter target in HTML

Parameter target in HTML

Image as a link in HTML

Image as a link in HTML

Post comment

basicuse.net
html5_css
106160485398655174790

Quick navigation

General navigation