What is target _blank in a href?
The short answer is: just add a
target="_blank" attribute to your links (anchor tags). Html code to open link in new tab?
For example, if you have a link that says the following:
Change the above so that it now says:
Now when your visitors click that link, it will open in a new window or tab (depending on which web browser they are using and how they configured that browser).
Note that if your web page uses the “strict” DOCTYPE of XHTML 1.0 or 1.1, you will not be able to do the above and still have your page validate as correct. However, I suspect virtually nobody uses those, so don’t worry if you don’t understand what I just said in this paragraph. The “transitional” versions of those DOCTYPEs are fine, though, since the target attribute is still supported there.
I know that some new webmasters seem to have got the impression that causing external links to open in a new window helps to keep people from leaving your website. This is an erroneous assumption. If someone clicks on a link and wants to return to your site, they will simply hit the Back button on their browser. Most people, even non-computer-geeks, learn this feature of their browser within a short time of discovering the Internet. The power users learn, in addition, how to right-click a link and select “Open in a new tab” when they need a link to be displayed in a separate tab or window.
HTML code open link tab in HTML. Html code to open link in new tab. Open in a new tab HTML link attribute, HTML need text add text.Html code to open link in new tab
When you create links that open in a new window, you are actually preventing newcomers from returning to your website. You may think that they will know how to simply switch back to the original window. My experience with such people suggests otherwise; they are stymied by the Back button not working, and are not even aware that they are looking at a new tab or window. When they can’t figure out how to solve the problem, they will give up and move on to other things.
Target _blank HTML open link, in new tab HTML Html code to open link in new tab href https, target attribute HTML code. Html code to open link in new tab
The situation is not better with experienced users. While they can figure out that they are looking at a new tab or window, and can switch back, they tend to get very irritated at your site for opening windows without their permission. After all, they are power users: if they wanted to open a new window, they will open it themselves; they don’t want you to do it without their consent. It’s worse if all your links open in new windows (leading to the comedic situation described in my article about usability mistakes made by amateur webmasters).
Open link tab target _blank new tab, Html code to open link in new tab, open in a new tab HTML. Html code to open link in new tab
At the time this is written, when you open a new page with
target="_blank", the site you link to gains access to the window/tab containing your page and is able to change it (in the visitor’s browser) to display a different web address.
Target link HTML code new tab _blank target. Html code to open link in new tab
This not only thwarts your attempt to keep visitors at your site (if that’s your purpose), it’s also a potential danger to them. For example, if you have a login page, the linked-to site may replace it with one on another site that looks like yours, but actually collects your visitor’s login details. This kind of attack is called “phishing”. Even if your site does not have facilities for visitors to log in, the linked-to site can replace it with a page that delivers malware.
This vulnerability is not hypothetical. The people from the Google Security Team have noted a “significant number of reports” of such “tabnabbing” being used to deliver malware.
Html code to open link in new tab
You can prevent it from happening in some browsers by adding
rel="noopener noreferrer" to your link. With this added, the above example becomes:
rel="noreferrer" is sufficient to prevent this problem, with this being the correct attribute to use. (The other one,
rel="noreferrer", has a side-effect in that the browser will also withhold the referring URL.) However, at this time, not all browsers support this. Likewise,
rel="noreferrer" is also not supported by some browsers. Since the list of browsers that support either attribute is not identical, if you want this protection from the greatest subset of browsers possible, you will probably need to use both.
Href add link HTML code add target HTML, href _blank target _blank. Link href target _blank HTML, link target _blank target _blank _blank HTML. Html code to open link in new tab
That said, the workaround only helps with the later versions of Chrome, Firefox, and Safari. Internet Explorer does not have such a facility, although, from my cursory test, version 11 seems to be immune to the attack in its default security zone. I’m not sure about Microsoft Edge.