Hyperlinks are the backbone of the web, connecting pages, resources, and ideas. Whether you’re building a website or writing a blog, understanding how to link pages internally (within your site) and externally (to other websites) is essential. In this tutorial, you’ll learn how to create hyperlinks, their SEO benefits, and best practices with a full example.
Table of Contents
What Are Hyperlinks?
A hyperlink (or link) is a clickable element (text, image, etc.) that directs users to another location. Links use the HTML <a>
tag with the href
attribute to specify the destination.
Syntax:
<a href="destination-url">Link Text</a>
Internal vs. External Links: Key Differences
Feature | Internal Links | External Links |
---|---|---|
Destination | Links within the same website. | Links to a different website. |
SEO Impact | Improves site navigation and SEO ranking. | Builds credibility and relationships. |
URL Structure | Uses relative paths (e.g., /about ). | Uses absolute URLs (e.g., https://example.com ). |
How to Create Internal Links
Internal links connect pages within your website. Use relative paths to keep URLs short and manageable.
Example: Linking to an “About” Page
File Structure:
├── index.html
└── about.html
HTML Code in index.html
:
<!DOCTYPE html>
<html>
<head>
<title>Home Page</title>
</head>
<body>
<h1>Welcome to My Website</h1>
<p>Learn more <a href="/about.html">about us</a>.</p>
</body>
</html>
Key Notes:
- Use
href="/about.html"
ifabout.html
is in the same folder. - For subfolders:
href="blog/post1.html"
.
How to Create External Links
External links direct users to other websites. Always use absolute URLs (full web addresses).
Example: Linking to Google
<p>Search the web using <a href="https://www.google.com" target="_blank">Google</a>.</p>
Attributes Explained:
href="https://www.google.com"
: The full URL of the destination.target="_blank"
: Opens the link in a new tab (optional but useful for external links).
Complete Example: Combining Internal & External Links
Let’s build a simple website with two pages (home.html
and contact.html
) and an external link.
Step 1: Create home.html
<!DOCTYPE html>
<html>
<head>
<title>Home Page</title>
</head>
<body>
<h1>Welcome to My Site</h1>
<nav>
<a href="/home.html">Home</a> |
<a href="/contact.html">Contact</a>
</nav>
<p>Check out our <a href="https://www.tutorialspoint.com" target="_blank">favorite tutorial site</a>!</p>
</body>
</html>
Output

Step 2: Create contact.html
<!DOCTYPE html>
<html>
<head>
<title>Contact Page</title>
</head>
<body>
<h1>Contact Us</h1>
<nav>
<a href="/home.html">Home</a> |
<a href="/contact.html">Contact</a>
</nav>
<p>Email us at <a href="mailto:contact@example.com">contact@example.com</a>.</p>
</body>
</html>
Output

Best Practices for Hyperlinks
Use Descriptive Anchor Text:
Avoid “click here.” Instead, write “Read our SEO guide.”
Add title
Attributes for Accessibility:
<a href="/about.html" title="Learn about our mission">About Us</a>
Internal Linking for SEO:
Link to relevant pages to improve site structure and user engagement.
External Links:
Link to authoritative sites to boost credibility.
Read More Tutorials
- HTML Attributes: A Complete Guide for Beginners
- HTML Tags: Mastering Headings, Paragraphs, and Links for Beginners
- What is HTML? Understanding the Basic Structure for Beginners
- Mastering HTML Tables: The Ultimate Guide for Students
- HTML Forms: A Comprehensive Guide for Beginners
Conclusion
Hyperlinks make the web interconnected and user-friendly. By mastering internal and external linking, you’ll enhance navigation, SEO, and user experience. Practice with the examples above, and soon you’ll be linking like a pro!