To contact Ben MacGowan, please fill in the below form. Note that required fields are marked with a blue left border.

Close

Please fill in all required fields before submitting

Looking at links point _blank

As developers we create hyperlinks all the time, but do we really think about the purpose of the link and what code is best to meet that purpose?

When coding a link onto a web page, we have a number of options about the behaviour of the link e.g. rel, name, accesskey, title and target. In this post I want to talk about the target attribute and whether we should use the default (_self) value or change it based on the purpose of the link.

The most commonly used target attributes are the default (_self), which opens the link in the same window/tab and _blank which opens the link in a new window/tab. Both completely different and can heavily affect the journey a user has on the internet. If you are a developer, this should all be common knowledge to you, but if you are unaware of the values and what they achieve, you can find out more at w3schools.

As I mentioned above, the value you do select for your target can affect your user’s journey, but some developers think that it should be down to the user. Whether they want a link to open in a new window or not is their decision. So as developers should we determine what the behaviour of a link is, or leave it down to the user to right click and select their option?

Developers and designers should be steering our users – helping, not forcing. Like all other usability and accessibility techniques we use, we want to make their experience easier and more pleasurable. In most cases we know best because at the end of the day, it’s our job.

Internal links

Best practice is to keep any internal links as target="_self" thus preventing new windows being created every time a user navigates through your site. The only exceptions to this, logically, should be pop-ups and documents.

Pop-ups, however disliked they may be, will need to open in a new window. Otherwise they just wouldn’t be pop-ups would they?

“… but documents?”, I hear you say. Logically if you are linking to a PDF, or any document which may be viewable within a user’s browser, the first thing a user is going to do is close the document once they have finished reading. Therefore closing the window/tab without realising they have lost their place on your website. This way the document will open up in a new window, and once closed the user will find themselves back on your website ready to carry on browsing.

Documents which can be viewed within the browser can vary depending on what programmes, browser and plug-ins the user has got installed, but this way you can ensure that they either open in a new window/tab or it will default to open in an external application.

External links

Any links to external websites – any page which is outside of the current website they are on – should open up in a new tab using target="_blank".

Whilst this means that your visitors still have your website open, therefore raising the chance they will come back and browse your website more, it also means that from a usability point of view, the user can instantly recognise that they have moved away from your website and are now on another.

The only downside to this would be if the user does not have a browser which supports tabbed browsing e.g. IE6. Though there are very few of these browsers used, they do exist. If you are writing an article which links to multiple external websites, bear in mind that this will mean multiple new windows for these users.