If you want to open a link in a new browser window/tab, the common approach is to use the target=”_blank” attribute in your anchor tag. However, the target attribute is deprecated by W3C standards and your HTML won’t validate if you use it.
The common alternative is to use JavaScript but I don’t really like that — what happens if the user doesn’t have JavaScript enabled? Also, apparently JavaScript versions are more susceptible to pop up blockers (although I can’t confirm if this is really the case).
Smashing Magazine argue that links shouldn’t open in new windows, because it leads to bad user expectation as users expect links to open in the same window. They do say there are certain exceptions. I don’t entirely agree with this. I may not expect a window to open in a new window, but I don’t know if that necessarily leads to a bad user experience, you just go, oh it opened in a new window, right lets go there now…
One way to make the target attribute validate is to the XHTML transitional DocType:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Again though this isn’t ideal because of the other subtleties of using a transitional DocType instead of a strict one. So, that’s why I ask, what is the go with the target attribute? Is there an alternate, HTML only solution? Is everyone comfortable using the unobtrusive javascript way? Do I just need to harden up and do that?
BTW, I do realise its ironic that this post links to external sources using the deprecated target=”_blank” attribute. But that’s just the easiest way to do it in WordPress.