Coding Hubs School of AI – Best AI & Full Stack Courses in Delhi NCR | 100% Placement
Limited Offer: Get 50% OFF on AI & Full Stack Courses
📞 Call Now: +91 8448811540
Back to HTML Notes
Topic #309

link-target

The target attribute on <a> controls where a link opens — the same tab, a new tab, or (in old frame-based layouts) a specific frame.

Syntax

<a href="..." target="_blank">opens in a new tab</a>

Basic Example

<a href="https://developer.mozilla.org/" target="_blank" rel="noopener">
    MDN Web Docs (opens in a new tab)
</a>

Browser output: clicking opens MDN in a brand-new browser tab, while the original page stays open right where the visitor left it.

How It Works

ValueBehavior
_selfOpens in the same tab — this is the default, so writing it explicitly is rarely necessary
_blankOpens in a new tab or window
_parentOpens in the parent frame, if the page is embedded in one
_topOpens in the full body of the window, breaking out of any frames entirely

Important Attributes

AttributePurpose
targetSets where the link opens, per the table above
rel="noopener"Should always accompany target="_blank" — see External Links for the security reason why

Real-World Example

<p>Read our full <a href="/privacy-policy">Privacy Policy</a> on this site,
or the <a href="https://gdpr.eu/" target="_blank" rel="noopener">official GDPR guidance</a> (opens in a new tab).</p>

Internal link left at the default (_self); external reference deliberately opened in a new tab so the visitor doesn't lose their place on the page.

Common Mistakes

  • Adding target="_blank" to every single link out of habit, including internal ones — this fills a visitor's browser with unwanted extra tabs
  • Using target="_blank" without rel="noopener"
  • Relying on frame-related values (_parent, _top, named frames) in modern layouts that don't actually use frames — these only matter in frame/iframe-based page structures

Best Practices

  • Leave target at its default for internal navigation
  • Reserve target="_blank" for genuinely external destinations, or cases where losing the current page's state would be disruptive (like a long form)
  • Warn users when a link opens in a new tab, ideally in the visible or accessible text

Accessibility Considerations

Unexpected new tabs are disorienting for users relying on the back button, especially with screen readers or keyboard navigation. Add visually hidden text such as "(opens in a new tab)" inside links that use target="_blank".

SEO Considerations

No direct ranking effect — target only changes browser tab behavior, not how search engines crawl or evaluate the link.

Browser & Modern HTML Notes

Frame-based values (_parent, _top, named targets) are legacy from the frameset era of HTML and are rarely relevant outside of pages still using <iframe>-heavy layouts.

Mini Practice

  1. Build one internal link (default target) and one external link (target="_blank" rel="noopener") on the same sample page.
  2. Add accessible "(opens in a new tab)" text to a target="_blank" link.

Related HTML Notes

Want to go beyond the notes?

Join Coding Hubs School of AI's HTML course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available
💬 Talk to Advisor
1
WhatsApp

Latest from Our Blog

Insights on AI, Data Science, Full Stack & Career

View All Articles →