Links & Hyperlinks0%

Links & Hyperlinks

Beginner8 min readβ€’Updated: 2026-09-10
Study Materials

Links & Hyperlinks (Connecting the World Wide Web) 🌐

Welcome to Chapter 6: Links in HTML!

Have you ever wondered why the World Wide Web is called a "Web"?

Imagine a spider's web: every thread connects to another thread, creating an interconnected network where you can walk from any point to any other point.

In video games, imagine having a teleportation portalβ€”you step inside, and WHOOSH! You are instantly transported across oceans to a new world.

In web development, Hyperlinks (or simply links) are those teleportation portals! With one gentle mouse click or screen tap, a link can take you:

  • Across the globe to Wikipedia or YouTube.
  • To another page on your school website.
  • Straight down to an important announcement on the same page.
  • Even trigger a direct phone call or email on your smartphone!

Without links, the internet would just be billions of lonely digital documents trapped on isolated computer hard drives. Links tie the entire digital universe together!


The Anchor Element (<a>) βš“

In HTML, we create links using the <a> tag.

Why did the inventors of HTML pick the letter a? Because a stands for Anchor βš“!

Think of a big ship throwing its heavy iron anchor into the sea floor. The anchor hooks the ship firmly to a specific location. In the exact same way, the HTML <a> tag anchors a piece of text or an image to a web address!

Anatomy of an Anchor Tag:

HTML
<a href="https://mskinstitute.in">Visit MSK Institute</a>

Hyperlink & Attribute Anatomy Breakdown

Understanding anchor tags and destination attributes

Link Anatomy
<aOpening Tag

Defines a clickable hyperlink.

href="..."Destination Attribute

Hypertext Reference (URL to open on click).

Visit MSK InstituteClickable Text

User-facing anchor text on screen.

</a>Closing Tag

Closes the hyperlink element.

Live Rendered Link Preview:Visit MSK Institute
Hover or click to test link behavior!
  1. 1
    <a> (Opening Tag): Tells the browser: "Get ready, a clickable link starts here!"
  2. 2
    href Attribute: This is the most important attribute. href stands for Hypertext Reference. It holds the destination address where the user will land after clicking.
  3. 3
    Link Text: The readable words between <a> and </a>. This is what the user sees on their screen (usually styled in blue with an underline).
  4. 4
    </a> (Closing Tag): Marks the end of the clickable area.

The 3 Main Types of Links πŸ—ΊοΈ

Where can a link take you? There are three main destinations:

Output
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 3 TYPES OF HYPERLINKS β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β–Ό β–Ό β–Ό
1. External Links 2. Internal Links 3. Bookmark / Jump Links
(To another website) (Same website, other page) (Same page, scroll down)
e.g. https://google.com e.g. about.html e.g. #exam-schedule

An external link takes the user away from your website to a completely different website on the internet (like visiting Google, Wikipedia, or CBSE).

To create an external link, you must use an Absolute URLβ€”which means writing the complete full address starting with https://:

HTML
<!-- External Link to Wikipedia -->
<p>
Learn more about space exploration on
<a href="https://www.wikipedia.org">Wikipedia</a>.
</p>
Β 
<!-- External Link to Google -->
<p>
Need help with research? Try
<a href="https://www.google.com">Google Search</a>.
</p>
Important Warning
Important: Always include https://! If you write href="google.com" without https://, the browser mistakenly thinks you are looking for a local file named google.com inside your computer folder!

Imagine your school website has multiple pages:

  • index.html (The Home Page)
  • about.html (About Our Teachers)
  • courses.html (Available Courses)
  • contact.html (School Office Address)

When a visitor wants to move from the Home page to the About page, you use a Relative URL (pointing to a file inside the same website folder):

HTML
<!-- Simple Navigation Menu -->
<nav>
<a href="index.html">Home</a> |
<a href="about.html">About Us</a> |
<a href="courses.html">Our Courses</a> |
<a href="contact.html">Contact Office</a>
</nav>

Because these files live in the same project directory, you don't need https://β€”just the file name!


Have you ever visited a very long webpageβ€”like a long Wikipedia article or a complete school syllabusβ€”and wanted to jump straight to Chapter 10 without scrolling for 5 minutes?

You can create Jump Links that smoothly scroll directly to a specific section on the same page!

Step 1: Give your target heading an id:

HTML
<h2 id="sports-day">Annual Sports Day Schedule</h2>

Step 2: Link to that id using a hashtag (#):

HTML
<a href="#sports-day">Jump to Sports Day Schedule πŸƒ</a>

You can even create a handy "Back to Top" button at the very bottom of your page:

HTML
<a href="#top">Back to Top ⬆️</a>

Smart Action Links (Call, Email & WhatsApp) πŸ“±

Modern mobile phones, tablets, and laptops can perform smart native actions directly from an HTML link!

1. Click-to-Call (tel:)

When someone taps this link on their smartphone, their phone app opens with the phone number already dialed:

HTML
<!-- Click to Call School Office -->
<a href="tel:+918393042166">πŸ“ž Call School Helpline: +91 83930 42166</a>

2. Click-to-Email (mailto:)

When clicked, this opens the user's default email app (like Gmail or Apple Mail) with the "To" address and even a pre-written subject line ready to send:

HTML
<!-- Click to Compose an Email -->
<a href="mailto:contact@mskinstitute.in?subject=Admission%20Enquiry%20Class%2010">
βœ‰οΈ Email Admissions Office
</a>

You can create a link that opens a WhatsApp conversation with a preset greeting message:

HTML
<!-- Click to Chat on WhatsApp -->
<a href="https://wa.me/918393042166?text=Hello%20Sir%2C%20I%20want%20information%20about%20coding%20classes">
πŸ’¬ Chat with MSK Mentors on WhatsApp
</a>

Turning Images & Buttons into Clickable Links πŸ–ΌοΈ

You don't have to link only plain text! You can put almost any HTML element inside an anchor tagβ€”including images!

For example, when visitors click your school logo, you want them to return to the home page:

HTML
<!-- Clickable School Logo Link -->
<a href="index.html">
<img src="school-logo.png" alt="MSK Institute Home" width="120">
</a>

You can also style an anchor tag with colors and padding so it looks just like a modern rounded button:

HTML
<!-- Link styled as a Button -->
<a href="register.html" style="background-color: #FF6B00; color: white; padding: 10px 20px; text-decoration: none; border-radius: 6px; font-weight: bold; display: inline-block;">
Register for Free Demo Class πŸš€
</a>

Default Link Colors (How Browsers Display Links) 🎨

By default, every web browser styles links in three distinct states so users know what is happening:

Link StateDefault AppearanceWhat It Means
Unvisited LinkBlue with underlineA link you have not clicked yet.
Visited LinkPurple with underlineA page you have already visited in this browser before.
Active LinkRed with underlineThe exact moment your mouse button is held down over the link.

Common Beginner Mistakes (And How to Avoid Them) ⚠️

HTML
<!-- ❌ WRONG: Tries to find a file named "google.com" on your computer! -->
<a href="google.com">Google</a>
Β 
<!-- βœ… CORRECT: Full web address with https:// -->
<a href="https://www.google.com">Google</a>

2. ⚠️ Forgetting the Closing </a> Tag

If you forget to close </a>, the browser thinks everything below it until the end of your document is part of the link! Your entire page will turn blue and clickable!

HTML
<!-- ❌ WRONG: Missing closing tag! -->
<a href="about.html">About Us
<p>This whole paragraph accidentally becomes clickable too!</p>
Β 
<!-- βœ… CORRECT: Always close the anchor tag immediately -->
<a href="about.html">About Us</a>
<p>This paragraph remains normal text.</p>

Never write just "Click here" or "Read more". For students using screen-reader software (for visually impaired learners), "Click here" gives zero clue where the link goes!

HTML
<!-- ❌ BAD: Vague and inaccessible -->
To download syllabus, <a href="syllabus.pdf">click here</a>.
Β 
<!-- βœ… GOOD: Clear and descriptive -->
<a href="syllabus.pdf">Download Class 10 Science Syllabus (PDF)</a>.

4. ⚠️ Confusing href with src

Remember: Images use src (source). Links use href (hypertext reference)!

HTML
<!-- ❌ WRONG: Anchor tags do NOT use src! -->
<a src="contact.html">Contact Us</a>
Β 
<!-- βœ… CORRECT: Use href -->
<a href="contact.html">Contact Us</a>

Quick Summary

  • In HTML, hyperlinks are created using the <a> tag (Anchor tag βš“).
  • The href attribute (Hypertext Reference) specifies the destination web address.
  • External links point to other websites and must always start with https:// (Absolute URL).
  • Internal links point to other pages inside your own website folder (Relative URL, like about.html).
  • Jump links use #id-name to zoom directly to a specific section on the same page.
  • Use tel: for click-to-call phone numbers and mailto: for click-to-compose emails.
  • Images can be turned into clickable buttons by wrapping them inside <a>...</a>.
  • Always write meaningful, descriptive link text instead of generic words like "Click here".

Practice Quiz

Test your understanding with these multiple-choice questions:

1. What does the letter "a" stand for in the HTML <a> tag?

A. Action B. Address C. Anchor D. Article Answer: C Explanation: The <a> tag stands for Anchor, because it anchors a piece of text or media to a destination URL.


A. src B. link C. url D. href Answer: D Explanation: href stands for Hypertext Reference and specifies the destination URL where the user will be taken upon clicking.


A. <a href="www.google.com">Google</a> B. <a href="https://www.google.com">Google</a> C. <a link="https://www.google.com">Google</a> D. <a src="https://www.google.com">Google</a> Answer: B Explanation: External links require an absolute URL including the protocol https:// so the browser knows to connect to the external web.


A. <a href="syllabus">Go to Syllabus</a> B. <a href="#syllabus">Go to Syllabus</a> C. <a target="#syllabus">Go to Syllabus</a> D. <a id="syllabus">Go to Syllabus</a> Answer: B Explanation: An internal bookmark/jump link uses a hashtag (#) followed by the matching element's id.


A. call: B. phone: C. dial: D. tel: Answer: D Explanation: The tel: protocol (e.g., <a href="tel:+918393042166">) tells smartphones to open the telephone dialer.


Hands-on Practice Challenge 🎯

Open VS Code and create a file named school-portal.html.

Your Challenge:

Create a mini School Website Home Page with working links:

  1. 1
    Top Navigation Bar: Add internal links for Home, About School, Admissions, and Contact Office.
  2. 2
    Featured Section: Add an external link to Wikipedia's page on Indian Space Research (https://en.wikipedia.org/wiki/ISRO).
  3. 3
    Jump Link: Add a link at the top saying "Jump to Principal's Message", which smoothly scrolls down to an <h3 id="principal"> heading.
  4. 4
    Smart Action Bar: Add a helpline section at the bottom with:
  • A tel: link to your school office phone.
  • A mailto: link to the admissions office email.
  1. 1
    Open your file in Chrome or Edge and test clicking every single link!

Next Up: In Topic 6.2, we will explore Target Attributes & Hyperlink Securityβ€”how to open links in brand new browser tabs safely without exposing your website to hackers!

Next Lesson

Target Attributes & Security

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

PrevNext