DEV Community

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

Posted on

11 3 1 1 1

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

Image of Docusign

Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

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
GrahamTheDev
Comment hidden by post author
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

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more