Thursday 16 January 2014

use target="_blank"

Anchor links may have a target attribute which controls what happens when that link is clicked. 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. But are there good reasons to do so?

When you use target="_blank"

A bad reason: Because you like it that way.

Like it or not, target="_blank" is a change in default behavior. links opening within the same page is the default behavior ( as if the link had target="_self" on it ).

A bad reason: Just because you want user to never leave your page.

A bad reason: "Internal" links and "External" links are different.

A bad reason: The links is to a PDF

A bad reason: My client wants it that way.

A good reason: The user is working on something on the page, that might be lost if the current page changed.

<form>have target="_blank" too. It's a uncommon use case.

No comments:

Post a Comment