target
Controls where links and forms open their results: same tab, new tab, parent frame, or a named browsing context.
Overview
The target attribute specifies where to display the result of a navigation: a link click or a form submission. It accepts keyword values for well-known browsing contexts or a custom name to open content in a specific window or frame.
Applies to: <a>, <area>, <form>, <base>
Values
| Value | Where it opens |
|---|---|
_self | Same browsing context (the default) |
_blank | A new, unnamed browsing context (new tab or window) |
_parent | The parent browsing context. If no parent, behaves like _self. |
_top | The topmost browsing context. Breaks out of all nested frames. |
name | A named browsing context. Reuses it if already open; creates it otherwise. |
Security: _blank and noopener
Historically, target="_blank" gave the opened page access to window.opener, allowing it to redirect your original tab to a phishing page. This required adding rel="noopener" as a countermeasure.
Modern browsers now imply rel="noopener" for all target="_blank" links by default. However, adding rel="noopener noreferrer" explicitly is still recommended for clarity and to support older browsers.
Named Targets
Any string that is not one of the underscore-prefixed keywords becomes a named browsing context. If a window or tab with that name already exists, the browser navigates it instead of opening a new one. This is useful for "preview" workflows.
Targeting Frames and Iframes
You can target a specific iframe by matching the target value to the iframe's name attribute. Links and forms outside the iframe can load content into it.
_parent and _top
Inside nested iframes, _parent navigates one level up and _top navigates the outermost window. These are essential for breaking out of frame hierarchies, such as redirecting to a login page from inside an embedded widget.
Setting a Default with base
The <base> element can set a default target for all links and forms on the page. Individual elements can still override it.
Accessibility
Opening links in new tabs (target="_blank") can disorient users, particularly those using screen readers or who have cognitive disabilities. The user loses their back-button history and may not realize a new tab opened.
- Only use
_blankwhen there is a clear reason (external site, in-progress form would be lost). - Indicate that a link opens in a new tab, either visually (icon) or via text (e.g. "opens in new tab") or with
aria-describedbypointing to a hint. - Never force all links to open in new tabs via
<base target="_blank">unless the application context demands it (e.g. a link aggregator).
Limitations
- Popup blockers:
target="_blank"without a user gesture (e.g. triggered by JavaScript timers) may be blocked by popup blockers. - Named targets persist: A named window stays open until the user closes it. Subsequent links with the same target name reuse it, which can be confusing if the user forgot the window is open.
- Sandboxed iframes: The
sandboxattribute can block_topand_parentnavigation unlessallow-top-navigationis granted. - Mobile behavior: On mobile browsers,
_blankopens a new tab rather than a new window. Named targets may not behave consistently across mobile browsers.