Tutorials HTML Link Tag
Ch 6 / 40
Chapter 6 Beginner 8 min read HTML

HTML Link Tag — The Anchor Element

Links are what make the web a web. The HTML anchor tag <a> is one of the most powerful and most-used elements in all of HTML. In this chapter you'll learn every type of link, every key attribute, and the best practices that professional developers follow.

What you'll learn
The syntax of the <a> tag and what every part means
Key attributes — href, target, rel, title, download
External, internal, email, phone, and download links
Anchor links — jumping to a section on the same page
Security best practices with target="_blank"
Common mistakes and when to use links correctly

What is the HTML Anchor Tag?

The <a> tag — short for anchor — creates a hyperlink. It can link to another webpage, a section on the same page, an email address, a phone number, or a downloadable file. Without the <a> tag there would be no navigation on the web.

The most important attribute is href (Hypertext Reference), which specifies the destination of the link. The visible, clickable text placed between the opening and closing tags is called the link text or anchor text.

Key Attributes of the <a> Tag

The anchor tag supports several important attributes. Here is a complete reference:

Attribute Purpose Example Value
href The destination URL or target — the only required attribute for a working link "https://k2infocom.com"
target Where to open the link — same tab (_self, default) or new tab (_blank) "_blank"
rel Relationship between the page and the link destination — used for SEO and security "noopener noreferrer"
title Tooltip text shown on hover — provides extra context about the link "Go to K2infocom homepage"
download Prompts the browser to download the linked file instead of navigating to it "cheatsheet.pdf"
href="#id" Links to an element with that id on the same page — called an anchor link "#contact"

The target Attribute & Security with rel

The target attribute controls where the linked page opens. The most used value is _blank — but it must always be paired with rel="noopener noreferrer" for security.

target="_self"
Opens the link in the same tab — this is the default behaviour. You don't need to write it explicitly; it happens automatically when target is omitted. Use for all internal page links.
target="_blank"
Opens the link in a new browser tab. Commonly used for external links so users don't leave your site. Always pair with rel="noopener noreferrer" to prevent a security vulnerability called tab-napping.
rel="noopener noreferrer"
noopener prevents the new tab from accessing your page via window.opener — blocking a type of phishing attack. noreferrer hides the referring URL from the destination site. Together they are the security standard for any target="_blank" link.
rel="nofollow"
Tells search engine crawlers not to follow or pass SEO link juice to the destination URL. Use for paid links, user-generated content (comments), or any link you don't want to endorse to Google.
Security Rule
Whenever you use target="_blank", you must also add rel="noopener noreferrer". Without it, the opened page can use JavaScript to redirect your page — a real security vulnerability known as reverse tab-napping.

Code Examples — All Link Types Together

Here are all link types shown in a single working HTML block:

HTML — All Link Types
<!-- 1. External link — opens in new tab -->
<a href="https://k2infocom.com"
   target="_blank"
   rel="noopener noreferrer"
   title="Visit K2infocom">
  Visit K2infocom
</a>

<!-- 2. Internal link — same site, relative path -->
<a href="/courses.html">Our Courses</a>

<!-- 3. Email link -->
<a href="mailto:hello@k2infocom.com">Email Us</a>

<!-- 4. Phone link -->
<a href="tel:+919876543210">Call Us</a>

<!-- 5. Download link -->
<a href="/files/cheatsheet.pdf"
   download="HTML-CheatSheet.pdf">
  Download Cheat Sheet
</a>

<!-- 6. Anchor / jump link -->
<a href="#contact">Jump to Contact</a>

<!-- Target section (anywhere on page) -->
<section id="contact">
  <h2>Contact Us</h2>
</section>

Common Mistakes — Do's & Don'ts

Here are the most frequent link mistakes beginners make:

Do — Correct
<!-- Descriptive anchor text -->
<a href="/courses.html">
  View all courses
</a>

<!-- _blank always with rel -->
<a href="https://..."
   target="_blank"
   rel="noopener noreferrer">
  Docs
</a>
Don't — Wrong
<!-- Vague anchor text — bad for SEO -->
<a href="/courses.html">
  click here
</a>

<!-- _blank without rel — security risk -->
<a href="https://..."
   target="_blank">
  Docs
</a>
SEO Tip
Never use "click here", "read more", or "here" as link text. These phrases are meaningless to search engines and screen readers. Always use descriptive text that tells the user exactly where the link goes — e.g. "Download HTML Cheat Sheet" or "View Web Development Course".

Complete Example — Navigation with All Link Types

Here is a realistic HTML page demonstrating all link types working together in a typical website layout:

HTML — Complete Link Examples
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>K2infocom</title>
</head>
<body>

  <!-- Navigation with internal links -->
  <nav>
    <a href="/index.html">Home</a>
    <a href="/courses.html">Courses</a>
    <a href="#contact">Contact</a>
  </nav>

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

  <!-- Download link -->
  <a href="/files/html-cheatsheet.pdf"
     download="HTML-CheatSheet.pdf">
    Download HTML Cheat Sheet
  </a>

  <!-- Contact section (anchor target) -->
  <section id="contact">
    <h2>Contact Us</h2>
    <a href="mailto:hello@k2infocom.com">
      hello@k2infocom.com
    </a>
    <a href="tel:+919876543210">
      +91 98765 43210
    </a>
  </section>

</body>
</html>

Try It Yourself

Edit the links below and click Open in Editor to test them live in full screen.

Live Editor
✎ Editor
👁 Preview
Try This
Click the "Jump to Bottom" link in the preview — the page scrolls instantly to the <section id="bottom"> element. This is the anchor / jump link behaviour in action, with no JavaScript required.
Free Resource
HTML5 Cheat Sheet — All Tags & Attributes
One printable PDF covering every HTML5 tag including the anchor tag, all its attributes, link types, and best practices. Perfect for quick reference.
Download PDF
Featured Course — Enroll Now
Modern Web Development With AI
Master HTML, CSS, JavaScript, React, and Node.js in one industry-ready curriculum with real projects and placement support.
120+
Chapters
40 hrs
Content
10
Projects
4.9 ⭐
Rating
HTML5 CSS3 JavaScript React.js Node.js MongoDB AI Tools

Quick Check — Chapter 6

Expand each question to check your understanding before moving on to the multiple choice quiz.

Questions & Answers
href stands for Hypertext Reference. It is the attribute that specifies the destination of the link — where the browser should navigate to when the user clicks it. Without href, the <a> tag renders as text with no clickable behaviour. The value can be a full URL (https://...), a relative path (/about.html), an email (mailto:...), a phone number (tel:...), or a page section (#id).
Without rel="noopener noreferrer", a page opened with target="_blank" can access your page through window.opener in JavaScript. A malicious site could use this to redirect your page to a phishing site while the user is looking at the new tab — this attack is called reverse tab-napping. noopener cuts the window.opener reference, and noreferrer also hides your page URL from the destination site. Together they are the security standard for any external link that opens in a new tab.
An external link points to a page on a different website — it requires the full absolute URL starting with https://. An internal link points to another page on the same website — it uses a relative path (e.g. /about.html or ../courses/index.html). Internal links use relative paths so the site still works correctly if the domain changes. External links should include target="_blank" and rel="noopener noreferrer" while internal links typically open in the same tab.
A jump link (anchor link) uses a href value that starts with # followed by an ID — for example href="#contact". When clicked, the browser scrolls directly to the element on the page that has the matching id attribute — e.g. <section id="contact">. The id attribute must be unique on the page — no two elements should share the same id. Jump links are used in table-of-contents navigation, "Back to Top" buttons, and long single-page layouts.
For an email link, use the mailto: scheme in the href attribute: <a href="mailto:hello@example.com">Email Us</a>. Clicking it opens the user's default email client with the address pre-filled. You can also add a subject: mailto:email@example.com?subject=Hello. For a phone link, use the tel: scheme: <a href="tel:+919876543210">Call Us</a>. On mobile this dials the number directly; on desktop it may open a VoIP application.
"Click here", "here", and "read more" are meaningless out of context. Screen readers often list all links on a page for navigation — if every link says "click here", users relying on assistive technology cannot understand where any link leads. Search engines also use anchor text as a ranking signal — vague text provides no SEO value. Always write descriptive link text that explains the destination: "Download HTML Cheat Sheet", "View Web Development Course", or "Read our privacy policy".
Multiple Choice Questions
MCQ 1 of 4
Which attribute specifies the destination URL of an HTML link?
MCQ 2 of 4
Which value of target opens a link in a new browser tab?
MCQ 3 of 4
Which href scheme is used to create a link that opens the user's email client?
MCQ 4 of 4
Which attribute should always accompany target="_blank" for security?
Chapter Summary
  • The <a> (anchor) tag creates hyperlinks. The href attribute is required — it sets the link destination.
  • External links use a full URL (https://...). Internal links use relative paths (/page.html).
  • Use target="_blank" to open links in a new tab. Always pair it with rel="noopener noreferrer" to prevent reverse tab-napping.
  • mailto: opens the email client. tel: opens the phone dialler. Both are fully supported on all modern browsers and mobile devices.
  • The download attribute triggers a file download instead of navigation. Give it a value to set the suggested filename.
  • Anchor links (href="#id") scroll the page to the element with a matching id — no JavaScript needed.
  • Always write descriptive link text — never "click here". Good anchor text improves SEO and accessibility for screen reader users.
~8 min read
Beginner level
Chapter 6 of 40

Rate Us on Google

4.8 / 5
Enjoying this tutorial?
If this tutorial helped you, a 5-star Google review means a lot. It helps other learners discover our free content and motivates us to keep improving.
500+ Reviews (Target)
Write a Google Review
Join WhatsApp Channel