Back to HTML

External Links, target blank and rel noopener

Coding Tutorials Team 18 July 2026

Linking away from your own site raises two questions that have real answers: whether the link should open in a new tab, and what the rel attribute should contain. Both are frequently handled by copying whatever the last template did.

What target blank does

The target attribute set to blank opens the destination in a new tab or window instead of navigating the current one.

<a href="https://example.com/" target="_blank">External resource</a>

The intent is usually to keep the visitor on your site. Whether it achieves that is debatable, and the usability cost is not.

The case against opening new tabs

The back button stops working, which is the control most people reach for first, and on a new tab there is nothing to go back to. Users who wanted a new tab already know how to ask for one, through a modifier key or a middle click, and taking the decision away from them removes a choice they were capable of making.

On a phone the effect is more disruptive, since tab management is more awkward and a proliferation of tabs is harder to notice and clear. For screen reader users the change of context may not be announced at all, so the first sign that anything happened is that the back button no longer does what it should.

If you do use it, say so in the link text or with visually hidden text, so that the behaviour is announced rather than discovered. An icon alone is not sufficient, since it is not read out.

Where it is reasonable

There are cases with a genuine argument. A link inside a form the user has partly filled in would lose their work if it navigated away. A documentation link opened while following a tutorial is more useful alongside than instead of. A file download or a document viewer is arguably a different kind of destination. Outside situations like these, the default of navigating in place is usually the better choice.

The security problem noopener solves

A page opened with target blank historically received a reference back to the page that opened it, through a property available to its scripts. That reference allowed the new page to redirect the original tab to a different address.

The attack is straightforward: a user clicks a link, reads the new page, returns to the original tab, and finds what appears to be your site asking them to log in again. It is not your site. This was known as tabnabbing and it did not require any flaw in your code, only a link to a page that had been compromised.

<a href="https://example.com/" target="_blank" rel="noopener">Example</a>

The noopener value severs that reference. Modern browsers now apply this behaviour automatically for links using target blank, so the attribute is no longer strictly required in current browsers. Including it remains sensible, because it costs nothing, documents the intent, and protects users on anything older.

You may also see noreferrer, which additionally withholds the referring address from the destination. That has a genuine privacy use, and it also means your own analytics disappear from the other site's reports, so it is a deliberate choice rather than an automatic addition.

Search engine values in rel

Three values communicate the nature of a link to search engines. Nofollow indicates that you do not vouch for the destination, and is the traditional value for user generated content and untrusted links. Sponsored marks a paid or affiliate link. UGC marks a link created by a user, such as one in a comment.

<a href="https://shop.example.com/" rel="sponsored noopener" target="_blank">Buy</a>

Values are space separated and several can be combined. Marking paid links correctly is not merely advisory, since undisclosed paid links that pass ranking signals are treated as a manipulation of search results and can attract a penalty. Applying nofollow to every external link is a different mistake, because linking to genuinely useful sources is normal and expected behaviour that costs you nothing.

Indicating an external destination visually

Many sites append a small icon to links leaving the site. This is helpful when it is done consistently, since it sets expectations before the click rather than after. Generated content in CSS can add the icon automatically to any link whose address does not match your own domain, which avoids having to remember it on each one.

If you add such an icon, give it a text alternative or accompanying hidden text, because a decorative image conveys nothing to a screen reader. An icon with no announced equivalent is a visual convention that simply does not exist for part of your audience.

A sensible default

Navigate in place for ordinary editorial links, add rel values that describe what a link actually is, and reserve new tabs for the specific cases where losing the current page would cost the user something.