Falytom logoFALYTOM
Games
ToolsUI ComponentsServicesProductsAbout
LoginSign Up
menu
  1. Home
  2. /Web Development
  3. /Html
  4. /Link Targets
Your Progress0%
0 of 76 completed

Topics

Getting Started

  • What is HTML?
  • How the Web Works
  • Setting Up Your Environment
  • Your First HTML Page

HTML Document Structure

  • The DOCTYPE Declaration
  • The HTML Element
  • The Head Section
  • Meta Tags
  • The Body Element
  • HTML Comments

Text and Formatting

  • Headings (h1-h6)
  • Paragraphs
  • Line Breaks and Horizontal Rules
  • Text Formatting (Bold, Italic, etc.)
  • Quotations and Citations
  • Preformatted Text and Code
  • Subscript and Superscript

Links and Navigation

  • Creating Links
  • Absolute vs Relative URLs
  • Link Targets and Attributes
  • Email and Phone Links
  • Internal Page Links

Images and Media

  • Adding Images
  • Image Attributes
  • Image Formats
  • Figure and Figcaption
  • Responsive Images
  • Audio Elements
  • Video Elements
  • Embedding Content

Lists

  • Unordered Lists
  • Ordered Lists
  • Description Lists
  • Nested Lists

Tables

  • Table Basics
  • Table Headers and Footers
  • Spanning Columns and Rows
  • Table Captions
  • Styling Tables

Forms - Part 1 (Basics)

  • Introduction to Forms
  • Text Input Fields
  • Labels and Placeholders
  • Textarea Element
  • Checkboxes
  • Radio Buttons

Forms - Part 2 (Advanced)

  • Select Dropdowns
  • File Upload Inputs
  • HTML5 Input Types
  • Form Validation
  • Form Buttons
  • Fieldsets and Legends
  • Form Accessibility

Semantic HTML

  • What is Semantic HTML?
  • Header and Footer
  • Nav Element
  • Main and Article
  • Section and Aside
  • Div vs Semantic Elements
  • Time and Mark Elements

HTML5 Features

  • HTML5 Overview
  • Canvas Element
  • SVG in HTML
  • Geolocation API
  • Drag and Drop
  • Local Storage
  • Web Workers

Web Accessibility

  • Introduction to Accessibility
  • ARIA Attributes
  • Keyboard Navigation
  • Alt Text Best Practices
  • Color Contrast and Typography
  • Testing for Accessibility

Best Practices & SEO

  • HTML Best Practices
  • SEO Fundamentals
  • Meta Tags for SEO
  • Structured Data

Link Targets and Attributes

Controlling where links open and additional link functionality

The target attribute controls where a linked document opens, and additional attributes can enhance link functionality and security. Understanding these attributes helps you create better user experiences.

The Target Attribute

The target attribute specifies where to open the linked document. By default, links open in the same window or tab, but you can change this behavior.

Opening Links in a New Tab

The most common use of the target attribute is target="_blank", which opens the link in a new browser tab or window:

target-blank.html
<a href="https://www.example.com" target="_blank">
  Visit Example (opens in new tab)
</a>

<a href="https://www.google.com" target="_blank">
  Google (new tab)
</a>

Important Security Consideration

When using target="_blank", you should ALWAYS include rel="noopener noreferrer" for security reasons:

secure-blank.html
<!-- ✅ Correct - secure -->
<a href="https://www.example.com" target="_blank" rel="noopener noreferrer">
  External Site
</a>

<!-- ❌ Vulnerable to security risks -->
<a href="https://www.example.com" target="_blank">
  External Site
</a>

⚠️ Why is this important?

Without rel="noopener", the new page can access your page using window.opener and potentially redirect your users to a malicious site. The noreferrer value prevents the destination site from knowing where the traffic came from.

All Target Values

_blank

Opens the link in a new tab or window:

target-blank-example.html
<a href="document.pdf" target="_blank" rel="noopener noreferrer">
  View PDF (new tab)
</a>

_self (Default)

Opens the link in the same frame or tab (this is the default):

target-self.html
<a href="about.html" target="_self">About Us</a>

<!-- This is the same as not using target at all -->
<a href="about.html">About Us</a>

_parent

Opens the link in the parent frame. Used mainly with iframes:

target-parent.html
<!-- Inside an iframe -->
<a href="page.html" target="_parent">
  Open in Parent Frame
</a>

_top

Opens the link in the full body of the window, breaking out of any frames:

target-top.html
<a href="home.html" target="_top">
  Break Out of Frames
</a>

The Rel Attribute

The rel (relationship) attribute describes the relationship between the current document and the linked document.

noopener

Prevents the new page from accessing the opening page:

rel-noopener.html
<a href="https://external-site.com" target="_blank" rel="noopener">
  External Link
</a>

noreferrer

Prevents the browser from sending the referrer header (hides where the traffic came from):

rel-noreferrer.html
<a href="https://external-site.com" target="_blank" rel="noreferrer">
  Anonymous Link
</a>

nofollow

Tells search engines not to follow the link (useful for untrusted or paid links):

rel-nofollow.html
<a href="https://untrusted-site.com" rel="nofollow">
  Untrusted Link
</a>

<!-- User-generated content or sponsored links -->
<a href="https://sponsor.com" rel="nofollow">
  Sponsored Link
</a>

Combining Multiple Rel Values

You can combine multiple rel values by separating them with spaces:

rel-combined.html
<a href="https://external.com" target="_blank" rel="noopener noreferrer nofollow">
  External Untrusted Link
</a>

The Download Attribute

The download attribute prompts the browser to download the linked file instead of navigating to it:

download-attribute.html
<!-- Download with original filename -->
<a href="document.pdf" download>
  Download PDF
</a>

<!-- Download with custom filename -->
<a href="report-2024.pdf" download="Annual_Report.pdf">
  Download Annual Report
</a>

<!-- Download an image -->
<a href="photo.jpg" download="vacation-photo.jpg">
  Download Photo
</a>

Note: The download attribute only works for same-origin URLs. It won't force downloads from external domains due to security restrictions.

Practical Examples

External Links with Best Practices

external-links.html
<!-- Social media links -->
<a href="https://twitter.com/yourhandle" 
   target="_blank" 
   rel="noopener noreferrer">
  Follow us on Twitter
</a>

<!-- Documentation link -->
<a href="https://developer.mozilla.org" 
   target="_blank" 
   rel="noopener noreferrer">
  MDN Web Docs
</a>

<!-- Affiliate or sponsored link -->
<a href="https://partner.com/product" 
   target="_blank" 
   rel="noopener noreferrer nofollow">
  View Product (Sponsored)
</a>

Navigation Menu with Mixed Links

navigation-menu.html
<nav>
  <!-- Internal links (no target needed) -->
  <a href="/">Home</a>
  <a href="/about">About</a>
  <a href="/services">Services</a>
  
  <!-- External link in new tab -->
  <a href="https://blog.example.com" 
     target="_blank" 
     rel="noopener noreferrer">
    Blog
  </a>
  
  <!-- Download link -->
  <a href="/brochure.pdf" download>
    Download Brochure
  </a>
</nav>

Resource Downloads

downloads.html
<section>
  <h2>Download Resources</h2>
  
  <ul>
    <li>
      <a href="guide.pdf" download="Beginners_Guide.pdf">
        Beginner's Guide (PDF)
      </a>
    </li>
    <li>
      <a href="template.docx" download>
        Document Template (DOCX)
      </a>
    </li>
    <li>
      <a href="data.csv" download>
        Sample Data (CSV)
      </a>
    </li>
  </ul>
</section>

When to Use target="_blank"

✅ Good uses for target="_blank":

  • Links to external websites or different domains
  • Links that open PDFs or other documents
  • Reference materials users may want to keep open
  • Links to social media profiles
  • External documentation or help resources

❌ Avoid target="_blank" for:

  • Internal navigation within your site
  • Standard website navigation menus
  • Every single link (it annoys users!)
  • Links in a sequential flow or process

Accessibility Considerations

When using target="_blank", consider adding a visual indicator and warning text:

accessible-external-links.html
<a href="https://external.com" 
   target="_blank" 
   rel="noopener noreferrer">
  External Site 
  <span aria-label="(opens in new tab)">(opens in new tab)</span>
</a>

<!-- Or with an icon -->
<a href="https://docs.example.com" 
   target="_blank" 
   rel="noopener noreferrer">
  Documentation 🔗
</a>

This helps users understand that clicking will open a new tab.

Best Practices

  • Always use rel="noopener noreferrer" with target="_blank"
  • Don't overuse target="_blank" - respect user choice
  • Indicate when links open in new tabs (for accessibility)
  • Use rel="nofollow" for untrusted or paid content
  • Use the download attribute for file downloads
  • Keep internal site navigation in the same tab/window
  • Test all links to ensure they work as expected

Modern Browser Support

Good news! Modern browsers (Chrome 88+, Firefox 79+, Safari 12.2+) now automatically apply rel="noopener" behavior to target="_blank" links. However, it's still best practice to explicitly include it for older browsers and clarity.

Key Takeaways

  • target="_blank" opens links in a new tab
  • Always use rel="noopener noreferrer" with target="_blank" for security
  • rel="nofollow" tells search engines not to follow a link
  • The download attribute prompts file downloads
  • Don't overuse new tabs - it can frustrate users
  • Indicate to users when links open in new tabs
  • Use target attributes thoughtfully for better UX

What's Next?

Now that you understand link targets and attributes, you're ready to learn about special link types. In the next lesson, we'll explore how to create email and phone links that let users contact you directly from your webpage.

Know someone who'd find this guide helpful? Please share!

Previous
Absolute vs Relative URLs
Next
Email and Phone Links

Never Miss a New HTML Tutorial

Join 1,000+ developers learning HTML step-by-step. Get new tutorials, tips, and exclusive resources delivered to your inbox - completely FREE.

You might also like

UI Components

Ready-made components for your projects

Developer Tools

Boost productivity with handy generators

HTML Game

Learn HTML concepts through interactive gameplay

Join Our Web Development Training Program

Master frontend & backend development with hands-on projects.

Menu

Topics

Getting Started

  • What is HTML?
  • How the Web Works
  • Setting Up Your Environment
  • Your First HTML Page

HTML Document Structure

  • The DOCTYPE Declaration
  • The HTML Element
  • The Head Section
  • Meta Tags
  • The Body Element
  • HTML Comments

Text and Formatting

  • Headings (h1-h6)
  • Paragraphs
  • Line Breaks and Horizontal Rules
  • Text Formatting (Bold, Italic, etc.)
  • Quotations and Citations
  • Preformatted Text and Code
  • Subscript and Superscript

Links and Navigation

  • Creating Links
  • Absolute vs Relative URLs
  • Link Targets and Attributes
  • Email and Phone Links
  • Internal Page Links

Images and Media

  • Adding Images
  • Image Attributes
  • Image Formats
  • Figure and Figcaption
  • Responsive Images
  • Audio Elements
  • Video Elements
  • Embedding Content

Lists

  • Unordered Lists
  • Ordered Lists
  • Description Lists
  • Nested Lists

Tables

  • Table Basics
  • Table Headers and Footers
  • Spanning Columns and Rows
  • Table Captions
  • Styling Tables

Forms - Part 1 (Basics)

  • Introduction to Forms
  • Text Input Fields
  • Labels and Placeholders
  • Textarea Element
  • Checkboxes
  • Radio Buttons

Forms - Part 2 (Advanced)

  • Select Dropdowns
  • File Upload Inputs
  • HTML5 Input Types
  • Form Validation
  • Form Buttons
  • Fieldsets and Legends
  • Form Accessibility

Semantic HTML

  • What is Semantic HTML?
  • Header and Footer
  • Nav Element
  • Main and Article
  • Section and Aside
  • Div vs Semantic Elements
  • Time and Mark Elements

HTML5 Features

  • HTML5 Overview
  • Canvas Element
  • SVG in HTML
  • Geolocation API
  • Drag and Drop
  • Local Storage
  • Web Workers

Web Accessibility

  • Introduction to Accessibility
  • ARIA Attributes
  • Keyboard Navigation
  • Alt Text Best Practices
  • Color Contrast and Typography
  • Testing for Accessibility

Best Practices & SEO

  • HTML Best Practices
  • SEO Fundamentals
  • Meta Tags for SEO
  • Structured Data
Falytom logoFALYTOM

Learn technologies like HTML, CSS, JavaScript, React, NodeJS and more through interactive games, tutorials, components and free tools. Transform your businesses with AI chatbots, SEO-optimized websites, and professional development services.

© 2025 Tomilola Group
  • Facebook logo
  • Twitter logo
  • Instagram logo
  • LinkedIn logo
  • GitHub logo
  • YouTube logo