HTML target=_blank vs target=blank

HTML target=_blank vs target=blank

Understanding the Differences and Implications for Opening Links in a New Browser Tab

ยท

2 min read

Initially, I assumed that both actions, opening a link in a new tab (or window) in a browser, were the same. However, an important difference can be made by simply removing the underscore


The target attribute specifies where to open the linked document.

Example

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

With target=_blank,

Clicking on the link will result in it opening in a new tab. This means that if we continue to click on additional links, a new browser tab will open each time. This can lead to the creation of multiple tabs and may potentially frustrate the user, impacting their overall experience.

target _blank example


Use target=blank,

If we remove the underscore, the browser will open the link in a tab named 'blank' instead of opening a new one. As a result, if the user clicks on multiple links, all the links will open in a single tab.

Example

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

target blank example


Demo


Conclusion

๐Ÿ‘๐Ÿ‘ I hope that by reading this far, you have gained the knowledge to implement the awesome target attribute trick in your project. I encourage you to try it out and enjoy its benefits.

Please feel free to share your thoughts and opinions with me, and if you encounter any issues or have any questions, don't hesitate to leave a comment.

Till then, Keep on Hacking, Cheers

ย