Why an HTML Link Target Name Opens an Existing Tab

Learn why a named HTML link target can reuse an existing tab, how it differs from _blank, and what to check for iframes and accessibility.

Published
Reading time
5 min read
Why an HTML Link Target Name Opens an Existing Tab
On this page

If an HTML link with a target name opens an existing tab, the browser may be doing exactly what the page requested. A named target can direct multiple links to the same browsing context, while _blank requests a new one.

This guide explains the distinction, provides a small reproduction, and covers iframe and accessibility considerations. It describes the HTML Living Standard’s target-selection model, but the standard was not retrieved for this article; verify browser-specific details in your supported environments.

Key Takeaways

  • A named target such as target="docs_view" can reuse a matching browsing context instead of creating a new tab for every click.
  • target="_blank" requests a new browsing context. Whether it appears as a tab or window depends on the browser and user settings.
  • A named target can also refer to an iframe, and sandboxing or browsing-context isolation can change the result.
  • Tell users in the link text when navigation may open or reuse another tab or window.

The target attribute tells the browser where to display the linked resource. A browsing context is an environment in which a document is displayed, such as a tab, window, or iframe.

TargetIntended destination
_selfThe current browsing context.
_blankA new browsing context for the navigation.
docs_viewA matching named browsing context, if one is available and can be targeted; otherwise, a new one may be created.

For example, if a link opens a new context named docs_view, a later link with the same target can navigate that context to a different URL. The second click may therefore replace the page in the existing tab rather than create another tab.

Named targeting is not a guarantee of reuse. Browser isolation, sandbox restrictions, link relationship attributes, and user actions can affect whether a matching context can be used. Also, the destination might be a window or an iframe rather than a tab.

Advertisement

Reproduce the behavior

Save the following as target-demo.html in an otherwise suitable local directory. The links load the same page with different query strings, so you can distinguish the navigations by checking the destination’s address bar.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Named target demonstration</title>
</head>
<body>
  <h1>Named target demonstration</h1>
  <p>Each link opens or reuses a separate tab or window.</p>
  <ul>
    <li><a href="?view=one" target="docs_view">Open view one</a></li>
    <li><a href="?view=two" target="docs_view">Open view two</a></li>
  </ul>
  <p>Check the address bar to see which view is loaded.</p>
</body>
</html>

With Python installed, serve the directory containing the file:

python3 -m http.server 8000

Open http://localhost:8000/target-demo.html, then:

  1. Activate Open view one. A separate tab or window is expected to open with ?view=one in its address.
  2. Return to the original page and activate Open view two. The browser is expected to navigate the existing docs_view context to ?view=two.
  3. For comparison, replace both target values with _blank and repeat. Each ordinary activation requests a new browsing context.

Close the server with Ctrl+C when finished. This example has not been executed here; browser settings, extensions, and how you activate the links can affect the result.

Advertisement

What changes inside an iframe?

A link in an iframe participates in target selection from that iframe’s browsing context. A named target can refer to another reachable context, potentially including a named iframe rather than a separate tab. For example, a page can contain an iframe whose name matches a link’s target; the link may then load its destination inside that iframe.

Do not assume that a name visible elsewhere in the browser is always reachable. An iframe’s sandbox restrictions can prevent popups or particular navigations. Browsing-context isolation can also separate pages that would otherwise be able to interact. If a link behaves differently inside an embed, inspect the iframe’s sandbox attribute, the target name, and the response headers and browser settings that affect isolation. Test the actual embedding arrangement in each browser you support.

Accessibility: make the destination behavior clear

Opening another browsing context can disorient users, particularly when they use screen readers or keyboard navigation. Prefer ordinary same-context links when a separate context is not needed.

When it is needed, include the behavior in visible link text or nearby text that also conveys it to assistive technology. For example:

<a href="guide.html" target="guide_view">
  Read the guide (opens or reuses a separate tab or window)
</a>

Do not promise that the destination will always be a new tab: a named target may reuse an existing context, and the browser may display a window instead. Users may also choose their own navigation behavior.

Common Mistakes

  • Expecting a unique tab from a shared name. Repeated target="docs_view" values are a request to use the same named destination when possible.
  • Assuming a name means a tab. The matching context could be an iframe or a window.
  • Ignoring link relationship attributes. For links with rel="noopener", a non-special named target is treated like _blank when deciding whether to create a new context, so reuse should not be expected.
  • Treating the demo as a production security pattern. If links lead to another site, consider opener isolation and the security trade-off of noopener; do not remove a security control solely to make reuse work.
  • Assuming focus will move predictably. Browser behavior and user preferences can determine whether the destination is foregrounded.

Best Practices

Use _blank when the intent is to request a fresh context, and use a named target only when replacing content in a shared destination is intentional. Choose a descriptive name, explain the navigation behavior to users, and test the links both directly and in any iframe where they will be embedded.

Conclusion

A shared target name can make links reuse an existing browsing context; _blank instead requests a new one. If the result differs from your expectation, check for matching iframe names, sandboxing, isolation, and attributes such as rel="noopener".

What would your domain sell for?

A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.