Alternative to _blank

As anyone who has tried to validate a website to a Strict doctype knows, the target="_blank" attribute is no longer allowed. The most common question is Why? and there is a simple answer.

In web standards, (X)HTML is for content, CSS is for style, and Javascript is for the behaviors. Opening a new window is not content, nor is it style, it is a behavior. Therefore, it does not belong as a component of the content tags (in this case, the <a> tag).

Now, we obviously don’t want to lose the ability to open a new window for an offsite link. Companies want their webpages to stay open while you see the associated content, not have to leave entirely for it. The solution then, should be obvious, you can handle this behavior through Javascripting.

The absolute best solution I’ve seen to this utilizes the rel attribute of the <a> tag, and turns…

<a href=”document.html” target=”_blank”>external link</a>

Into…

<a href=”document.html” rel=”external”>external link</a>

The solution comes from Sitepoint and can be viewed here with the full instructions and associated Javascript.

Perhaps in the future, when more and more people are using browsers with better tabbing abilities and auto-tab-opening of off-site links, this won’t be an issue anymore. For now, this is a solution.

~Nicole