Module 5: Links and Navigation
Opening Links in a New Tab
Use target and rel deliberately and avoid surprising or unsafe external-link behavior.
The target attribute controls where a linked resource opens. The common value _blank asks the browser to open a new browsing context, often a new tab.
<a href="https://developer.mozilla.org/"
target="_blank"
rel="noopener">
Open MDN in a new tab
</a>
Modern browsers generally imply noopener behavior for _blank, but including it can make the intent explicit. noopener prevents the opened page from receiving a reference to the original page through window.opener. Add noreferrer only when you also intend to suppress referrer information.
Should every external link open a new tab? Usually not. Unexpected new tabs can disorient visitors, particularly people using screen readers or keyboard navigation. Let links open in the current tab unless there is a clear reason to do otherwise. If a new tab is important, make that behavior clear in the link text or nearby context.
noopener is a browsing-context protection, not a filter that makes an unsafe URL safe. Validate user-supplied destinations on the server before turning them into links.