🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
HTML MASTER CLASS /// LEARN TAGS /// BUILD STRUCTURE /// SEMANTIC WEB /// HTML MASTER CLASS /// LEARN TAGS ///
Total XP: 0|💻 html XP: 0

HTML Links: Connecting the Web

Master the HTML anchor tag. Learn the difference between absolute and relative URLs, how to open links in new tabs, jump to specific page sections, and trigger email or phone actions.

LOADING ENGINE...

Skill Matrix

UNLOCK NODES BY LEARNING NEW TAGS.

Navigation Node

Web Connectivity.


Hyperlinks are the fundamental building blocks of the World Wide Web, transforming isolated documents into an interconnected global network. By utilizing the HTML anchor tag, developers seamlessly guide users between distinct web pages, downloadable resources, or entirely different applications.

1The Anchor Element and Href

To create a functional link, you must use the anchor element (<a>) paired with its most critical attribute: href (Hypertext Reference). The anchor tag acts as a vehicle, but the href attribute dictates the exact destination URL the browser should navigate to when the user clicks the enclosed text.

Without this required attribute, the anchor element is semantically broken. It becomes a useless inline element rather than an interactive gateway to another document.

+
<!-- Broken: Missing href attribute -->
<a>Click here</a>

<!-- Valid: Directs to destination -->
<a href="https://developer.mozilla.org">
  MDN Web Docs
</a>
localhost:3000

Click here

MDN Web Docs

2Absolute vs. Relative URLs

When defining the href destination, you can use either absolute or relative URLs. An absolute URL includes the complete web protocol (like https://) and domain address. This is strictly mandatory for linking to external websites on different servers.

A relative URL (like /about.html) acts as a localized shortcut for linking to pages within your own website's directory structure. It is highly preferred for internal routing because it makes your codebase portable; you can move the entire project to a new domain without breaking thousands of internal links.

+
<!-- Absolute URL (External site) -->
<a href="https://github.com">GitHub</a>

<!-- Relative URL (Internal site) -->
<a href="/dashboard/settings">Settings</a>
localhost:3000
Leaving site ➡️ https://github.com
Internal route ➡️ localhost:3000/dashboard/settings

3Managing Tab Behavior

By default, browsers execute link navigation within the current active tab. This is perfect for internal routing, but when linking out to external resources, it forcefully rips the user away from your application.

It is a UX best practice to keep your web app open and launch the new external site in a separate window. You achieve this by applying the target="_blank" attribute to the anchor tag. Always pair this with rel="noopener noreferrer" to prevent the new tab from maliciously hijacking your original application's process via the window object.

+
<!-- Opens safely in a new background tab -->
<a
  href="https://external-resource.com"
  target="_blank"
  rel="noopener noreferrer"
>
  External Resource ↗
</a>
localhost:3000

4Internal Anchors and Protocols

Hyperlinks are incredibly versatile. By assigning a unique id attribute to a target element, you can create an internal 'jump link' using an href value starting with a hash symbol (like #pricing). This scrolls the user directly to that section without reloading the page.

Furthermore, anchor tags can trigger deep system-level actions via specialized protocols. Using the mailto: protocol launches the user's default email client, while the tel: protocol initiates a phone call directly from mobile devices. The download attribute forces the browser to instantly save the payload to the user's drive rather than attempting to render it.

+
<!-- Jump Link -->
<a href="#contact-section">Jump down</a>

<!-- System Email Trigger -->
<a href="mailto:[email protected]">Email Support</a>

<!-- Target for Jump Link -->
<h2 id="contact-section">Contact Us</h2>
localhost:3000

?Frequently Asked Questions

Pascual Vila

Pascual Vila

Frontend Instructor // Code Syllabus

Lesson Glossary

[01]Hyperlink

A reference to data that the user can follow by clicking or tapping.

Code Preview
<a>

[02]href

Hypertext Reference. The attribute that specifies the URL of the page the link goes to.

Code Preview
href='url'

[03]Absolute URL

A full web address including the protocol (https://) and domain name.

Code Preview
https://domain.com

[04]Relative URL

A path to a file within the same website, omitting the domain name.

Code Preview
/about.html

[05]target='_blank'

An attribute value that forces the browser to open the linked document in a new tab or window.

Code Preview
target='_blank'

[06]mailto:

A URL scheme used to produce a hyperlink that allows users to send an email.

Code Preview

Continue Learning