Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

Difference between “blank” and “_blank” target attributes in HTML

  • Last Updated : 03 Aug, 2021

If you have ever noticed on the website that few links got opened either in a new tab or in a new window or sometimes, it might also happen that in some websites, click on the link, for the first time, it will open in a new tab & that particular open tab will update & reused every time whenever we click to the link. Both these scenarios can be possible by using the HTML target attribute. In this article, we will see how to use of target=”blank” & target=”_blank” attribute to open a hyperlink in another tab. If you don’t know, please refer to How to open a hyperlink in another window or tab in HTML?. We will discuss both attributes one-by-one. Let’s first see target=”blank”.

1. target=”blank”: if we set the target as “blank” then after clicking on a link or after submitting a form, it’s going to open a browser tab for the first time and it will be reused the same tab. The purpose of using this attribute is to keep the user engagement on your website without much effort to search & visit the offsite link every time in a separate tab. It also helps the user’s browser light to use as too many open tabs might hamper the performance of the overall browser as well as affect the system & it is also possible that the browser may get hanged up.

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

Example:

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>target="blank"</title>
</head>
  
<body>
  
    <!-- It will open a new browser 
        tab for the first time and 
        after that it will reuse 
        that open tab -->
    <p>Using target="blank"</p>
  
    <a href="https://www.geeksforgeeks.org/" 
        target="blank">
        Open GFG
    </a>
</body>
  
</html>

Output:



Using target=”blank”

From the above output, we can see that on click the link for the first time, it will open in the new tab & every time whenever we click on the same link, it will redirect to that particular open tab.

2. target=”_blank”: if we set the target as “_blank” then after clicking on a link or after submitting a form it’s going to open a  new browser tab every time. The purpose of using this attribute is to keep the users engaged on your site for a long time that will improve most of your metrics: bounce rate, conversion, pages visited etc.

Example:

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>target="_blank"</title>
</head>
  
<body>
  
    <!-- It will open a new browser 
        tab every time -->
    <p>Using target="_blank"</p>
  
        target="_blank">
        Open GFG 
    </a>
</body>
  
</html>

Output:

Using target=”_blank”

From the above output, we can see that whenever on click the link, it is targeting the new tab for each click.

Differences between target=”blank” and target=”_blank”. 

 

target=”blank”

target=”_blank”

1.

To open the offsite link in a separate tab for the first time & keep on reuse the same tab whenever linked is clicked. 

To open the offsite link in the separate tab or window. 

2.

Opens a new browser tab for the first time & after it will be reused. For this reason, the browser may work efficiently.

Opens a new browser tab every time. This may affect the overall performance of the browser as well as affect the system also.




My Personal Notes arrow_drop_up
Recommended Articles
Page :