Sunday 8th November 2009
After reading an article on New-Window Links in a Standards-Compliant World by Kevin Yank a few years back, I adopted the practice of no longer using the
target='_blank' attribute, in order for my websites to validate. But I still wanted the ability to open links in a new window in an unobtrusive and accessible way. So I started using a small and useful script, external.js.
<!--Old, deprecated html:-->
<a href=" http://www.google.com " target='_blank'>external link</a>
<a href="http://www.google.com" rel="external">external link</a>
External.js uses the rel attribute of links to specify which links should be opened in a new window. If you have a link on your website with
An issue with using this is that the the rel attribute has a number of pre-defined standard values, of which "external" is not one. But the rel attribute is intended to specify the relationship between the document that contains the link, and the target of the link. And it is allowed to take any value, even a space separated string. So you can use
rel="external" and your code will still validate. Also, the value "external" does help to specify the relationship between the document and the links target, in most cases where it is used.