HTML target Attribute

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The target attribute names the browsing context (tab, window, or <iframe>) where a linked URL or form response should open. On <a>, it works with href.

Also used on <form>, <base>, and image-map areas. Submit buttons can override with formtarget. Pair new-tab links with clear text and often rel.

Baseline · Widely available.

Not deprecated. Standard attribute for links and forms across modern browsers. Default when omitted is the current context (_self).

Warn users before _blank.

Per MDN: unexpected new tabs confuse many people. Put “(opens in new tab)” (or similar) in the link text when you use target="_blank".

HTML Syntax

syntax.html
<a href="…" target=" name">

name is a keyword (_self, _blank, …) or a custom browsing-context name (e.g. an iframe’s name). Equivalent JS: a.target = "_blank".

Attribute Values

Special keywords (MDN) and a named frame:

ValueDescriptionTry it
_selfCurrent browsing context (default)Try it
_blankUsually a new tab (user may choose a window)Try it
_parentParent frame; else like _selfTry it
_topTopmost frame; else like _selfTry it
Custom nameNamed window/iframe (matches iframe name)Try it

Note: _unfencedTop is a newer reserved name for fenced-frame cases — not needed for everyday links.

Live Preview

Pick a target value. The sample link updates so you can inspect the markup (clicking may open a tab — that is expected for _blank).

Uses example.com. Prefer warning text when choosing _blank.

Link

Example site

target="_self" — same tab / context

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Open in the Same Tab

Default behavior — stay in the current browsing context.

HTML
<a href="https://example.com/" target="_self">
  Example site
</a>

<!-- Omitting target is the same as _self -->
<a href="https://example.com/">Example site</a>
Try It Yourself

How It Works

  1. target="_self" loads the URL in the current context.
  2. Omitting target does the same — this is the usual default.
  3. Best for most in-site links — users keep their back button history in one tab.
  4. Prefer this unless you have a strong reason for a new tab.

Example 2 — New Tab with a Clear Warning

MDN pattern: tell people a new tab will open; keep rel explicit.

HTML
<a href="https://www.wikipedia.org/"
   target="_blank"
   rel="noopener noreferrer">
  Wikipedia (opens in new tab)
</a>
Try It Yourself

How It Works

  1. _blank asks for a new tab (or window, per user settings).
  2. Link text warns so the change is not a surprise.
  3. rel="noopener" avoids giving the new page window.opener (modern browsers also imply this for _blank on <a>).
  4. noreferrer is optional privacy hardening for the Referer header.

Example 3 — Named iframe, _parent, and _top

Inside frames: load a named iframe, the parent, or break out to the top page.

HTML
<iframe name="preview" title="Preview" width="320" height="120"
        src="about:blank"></iframe>

<p>
  <a href="https://example.com/" target="preview">Load in iframe</a>
</p>
<p>
  <a href="https://example.com/" target="_top">Open in top window</a>
</p>
Try It Yourself

How It Works

  1. Match names: target="preview" needs <iframe name="preview">.
  2. _parent goes one frame up; no parent → acts like _self.
  3. _top replaces the outermost page — useful to escape nested iframes.
  4. Always set title on iframes for accessibility.

Edge Cases & Pitfalls

Most issues are surprise new tabs, missing link text warnings, or opener security on older browsers.

a11y

Announce new tabs

Say “(opens in new tab)” in the visible link text — icons alone are not enough without accessible names.

security

noopener and _blank

Modern browsers imply noopener for a[target=_blank]. Explicit rel="noopener" remains a good habit for clarity and older engines.

popup

User settings win

_blank often means a tab, but browsers/users may open a window instead. Don’t assume UI chrome.

forms

Form vs button override

target on <form> sets the default; formtarget on a submit control can override it.

base

<base target> is global

A <base> target changes the default for the whole document — use carefully.

Browser Support

target is an HTML attribute for links and forms in the browser. It is not a Node.js, Deno, or Bun API.

✓ Widely available

target

Supported everywhere for a, form, area, and base. Accessibility quality depends on how you use _blank.

98% Global support (approx.)
Google Chrome All modern
Full support
Mozilla Firefox All modern
Full support
Apple Safari All modern
Full support
Microsoft Edge All modern
Full support
Opera All modern
Full support
Samsung Internet Modern
Full support
Internet Explorer All
Supported
target Widely supported

Bottom line: Safe to use. Prefer _self by default; when using _blank, warn in the link text and keep rel="noopener".

Key Takeaways

  • Role: choose where a link/form result opens.
  • Default: _self (same context) when omitted.
  • _blank: warn in text; keep rel="noopener".
  • Frames: named targets, _parent, and _top.

One line: target picks the tab/frame — default same page; new tabs need a clear warning.

Frequently Asked Questions

It names the browsing context (tab, window, or iframe) where the linked URL or form response should open. On links, common values are _self (same tab) and _blank (new tab).
Mainly a, area, form, and base. Forms also have formtarget on submit buttons for a per-button override.
Same as target="_self": the link or form result loads in the current browsing context.
Older pages needed rel="noopener" (and often noreferrer) because a new page could use window.opener. Modern browsers treat target="_blank" on anchors as implicitly noopener. Explicit rel="noopener" is still a clear, portable habit.
No. Opening a new tab can surprise users. Prefer _self unless there is a clear reason, and warn in the link text when you do use _blank (MDN accessibility guidance).
_parent loads in the parent frame; _top loads in the topmost frame. With no frames, both behave like _self. Useful inside iframes.

Next: title

Add advisory tooltip text with the global title attribute.

title tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful