DEV Community

Cover image for HTML target=_blank vs target=blank
⚡ Nirazan Basnet ⚡ for IntegridSolutions

Posted on

HTML target=_blank vs target=blank

Earlier I thought they both perform the same actions like opening a link to a new tab (or window ) in the browser. But, just removing the underscore can make an important difference.

The target attribute specifies where to open the linked document.

Example

<a href="https://www.google.com" target="_blank">Visit google Site</a>
Enter fullscreen mode Exit fullscreen mode

With target=_blank,

Whenever we click the link, it will open in a new tab. So, let's say if we click more links then, every time a new browser tab will open which can create multiple tabs, and maybe it can frustrate the user and its experience.

target _blank example


Alternate solutions we can use target=blank,

Now, let's remove the underscore, then the browser will open the link in a tab called 'blank' instead of opening a new one. With this, if the user will click multiple links then the links will open in a single tab.

Example

<a href="https://www.google.com" target="blank">Visit google Site</a>
Enter fullscreen mode Exit fullscreen mode

target blank example

Demo


Conclusion
👏👏 By coming this far I hope you can implement this awesome target attribute trick on your project. So, I suggest you give it a try on your project and enjoy it!

Feel free to share your thoughts and opinions and leave me a comment if you have any problems or questions.

Till then,
Keep on Hacking, Cheers

Top comments (4)

Collapse
 
leob profile image
leob • Edited

Right, so "_blank" is like a reserved word with a special meaning, while "blank" is just a name, and you could probably write "blanc" or "bianco" or whatever, with the same effect ;)

Collapse
 
grahamthedev profile image
Info Comment hidden by post author - thread only accessible via permalink
GrahamTheDev

They watched a YouTube video and copied it, can’t remember the video author sadly. The video Author made same mistake and now we will have inevitable echo chamber where hundreds of people will copy it blindly and think that is how it works 😜🤣🤣.

Collapse
 
leob profile image
leob • Edited

Yup ... looks like this post is doing more to spread and perpetuate a piece of confusion than to clear it up ... "_blank" is just a reserved word with a special meaning, so comparing it to "blank" is like comparing apples and oranges ;)

And yes, I just did a Google search and I see tons of blogs posts going on about exactly this same subject, so it's not like anything new and earth shattering has been uncovered here ... in other words, this is basic knowledge :)

Collapse
 
yatharthaa profile image
Sandip Bhandari

very usefull article, highly recommended

Some comments have been hidden by the post's author - find out more