Difference Between target="_blank" and target="blank" in HTML
I came across an interesting face while creating an HTML page for the client requirement. I am sharing this here with you.
My requirement was users should not be left from the current page when they click on any link. Also, there should not be too many tabs or windows opened when the user navigates through the links on the home page.
I know that you got the answer that you need to open the link in a new tab, but what to choose for a target between "_blank" vs. "blank".
What is the Target Attribute in HTML?
In HTML, "target" is an optional attribute of the anchor tag. The target attribute is an HTML attribute that specifies where to open the linked document when a user clicks on a hyperlink. It can be used with the <a> tag to specify the target window or frame for the linked document.
What are the different possible values of the Target Attribute in HTML?
The target attribute can take one of the following values:
- "_blank": It opens the linked document in a new window or tab.
- "_self": It opens the linked document in the same frame as it was clicked (this is default).
- "_parent": It opens the linked document in the parent frame.
- "_top": It opens the linked document in the full body of the window.
- "framename": It opens the linked document in the named iframe.
What is the meaning of target = "_blank" in the anchor tag of HTML?
If we pass the value "_blank" to the target attribute as, target="_blank" in an anchor tag, the link will always be opened in a new browser tab or window. It opens a new browser tab every time we click on the link. This attribute will not reuse a single new tab.
By using this attribute, the user can have a seamless way to explore different web pages while keeping the original page readily accessible. Also, this may affect the overall performance of the browser as well as affect the system.
<a target="_blank" href="https://www.crackjob.co.in/"> Crack Job </a>
This will allow you to open the same page in a new tab again and again after every click on the link given in the website.
What is the meaning of target = "blank" in the anchor tag of HTML?
In the case of the non-underscore target="blank", the blank part is just a name. It could be anything like target="foo".
<a target="foo" href="https://www.crackjob.co.in/"> Crack Job </a>
The target="blank" will open a new window at the very first time and this window will be reused after onwards for each request. It is the same as target = "framename".
So if we use target="blank" as the value to this attribute, the link will be opened in a new browser tab when clicked. The same tab will be reused for all the links with the same attribute (target=“blank”).
<a target="blank" href="https://www.crackjob.co.in/"> Crack Job </a>
Unlike the previous tag i.e. "_blank", this tag doesn't open a new tab each time when you click on the link. Rather after opening a new tab on the first click, you'll get switched to the same tab when you click on the link.
What is the difference between target="_blank" vs. target="blank"?
In HTML target="_blank" is a special keyword that will open links in a new tab every time. Here "_blank" is a reserved name that targets a new, unnamed window. A target=_blank is older than the concept of browser tabs. So it usually opens a new tab nowadays. So target="_blank" attribute will open the links in a new tab every time.
<a target="_blank" href="https://www.crackjob.co.in/">Crack Job</a>
On the other hand target="blank" attribute will open the links in a new browser tab and use the same tab for any future links that have the same attribute (target="blank"). So it will open the first-clicked link in a new tab, but any future links that share target="blank" will open in that same newly-opened tab.
<a target="blank" href="https://www.crackjob.co.in/">Crack Job</a>
The blank targets an existing frame or window called "blank". A new window is created only if "blank" doesn't already exist.
Wrap Up
So, 𝙩𝙖𝙧𝙜𝙚𝙩="𝙗𝙡𝙖𝙣𝙠" and 𝙩𝙖𝙧𝙜𝙚𝙩="_𝙗𝙡𝙖𝙣𝙠" are two different things in HTML. The target="_blank" will always open a new window or tab but target="blank" will open a new window at the very first time and this window will be reused after that for all the links which has the target as blank.
Recommended
- SQL Merge Statement - EVIL or DEVIL
- Difference Between React vs. Angular
- Difference Between Constructor vs. NgOnInit in Angular
- Constructor Execution Order in C#
- Difference Between padding vs. margin in CSS
- Constructor Execution Order in C#
- Difference Between padding vs. margin in CSS
- Difference Between document.ready() vs. window.onload() in jQuery
- Difference Between target="_blank" vs target="blank" in HTML
Tags:
html-interview