Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is target="_blank" not advisable to use with XHTML?

It's valid in XHTML 1.1 and WCAG 2.0 guidelines don't have any info about its usage?

I know it's not valid in XHTML 1.0 strict, but if many people are using other things like JavaScript, jQuery, rel attribute, PHP etc.

Does it make sense? It means people don't want to follow validation rules, they just want to skip the validation.

like image 930
Jitendra Vyas Avatar asked Feb 12 '10 07:02

Jitendra Vyas


People also ask

Why target _blank is deprecated?

There's A Security Reason For Not Using _BlankThe target=”_blank” link attribute is risky and opens a website to security and performance issues. Google's Web. dev page on the risks of using the _blank link attribute is summarized as such: “The other page may run on the same process as your page.

When should I use target _blank?

target="_blank" is a special keyword that will open links in a new tab every time. target="blank" 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.

What does target _blank mean in HTML?

Description. _blank. Opens the linked document in a new window or tab. _self. Opens the linked document in the same frame as it was clicked (this is default)

When should the target _blank attribute be used in a hyperlink?

One of the possible values of that attribute is _blank , which tells the browser to open a new window (or tab, if that's the user's preference) when that link is clicked. This used to be “invalid” in HTML (maybe only XHTML?) but people used it anyway since it worked. It's now perfectly valid in HTML5.


2 Answers

It's mainly to do with separating content from behaviour. The basic premise is that we should use HTML/XHTML to denote content, CSS for presentation and layout, and JavaScript for interactivity.

The target attribute doesn't fit in with this paradigm (it's a bit of HTML content that affects browser behaviour), which is why its use is frowned upon.

like image 54
Mark Bell Avatar answered Sep 17 '22 17:09

Mark Bell


Why are you trying to force the link to open in a new window in the first place? If the user want to view it in a new window or tab, they should be the one to decide. It's harmful for usability; for example, it stops the back button from functioning correctly, and takes some control out of the users hands. Check out this article for more.

Designers open new browser windows on the theory that it keeps users on their site. But even disregarding the user-hostile message implied in taking over the user's machine, the strategy is self-defeating since it disables the Back button which is the normal way users return to previous sites. Users often don't notice that a new window has opened, especially if they are using a small monitor where the windows are maximized to fill up the screen. So a user who tries to return to the origin will be confused by a grayed out Back button.

link

like image 45
Firas Assaad Avatar answered Sep 16 '22 17:09

Firas Assaad