The Quick Start
Hyperlinks and Anchors
- Beginner
- December 29, 2025
Fahim ul Haq is the co-founder and CEO of Educative, the world's leading upskilling platform for and by developers. He is a former software engineer at Microsoft and Facebook with a deep passion for creating better, more efficient ways for developers to master in-demand skills.
Hyperlinks are what turn individual web pages into a connected web. Without links, every page would exist in isolation, and the internet as we know it wouldn’t exist.
In this lesson, you’ll learn how hyperlinks work in HTML, how to create them using anchor tags, and how to link pages, sections, and external websites together. You’ll also practice building real links step by step so you can confidently use them in your own pages.
By the end of this lesson, you’ll understand not just how to create links, but how to use them thoughtfully and correctly.
What is a hyperlink?
A hyperlink is a clickable connection between one resource and another. That resource might be another page, a specific section on the same page, a file, or an external website.
When you click a link, the browser navigates to the location defined by that link. This simple action is the foundation of how users move through the web.
In HTML, hyperlinks are created using anchor elements, which is why links are often referred to as “anchors.”
The anchor tag (<a>)
All hyperlinks in HTML are created using the <a> tag. The “a” stands for anchor.
Here is the simplest possible link:
The text between the opening and closing <a> tags is the clickable part of the link. The href attribute tells the browser where the link should go.
When a user clicks this link, the browser navigates to the URL provided in href.
Understanding the href attribute
The href attribute stands for hypertext reference. It defines the destination of the link.
Without an href, the anchor tag does not function as a link. It may still appear clickable, but it won’t take the user anywhere.
The value of href can point to many different types of destinations, which you’ll explore throughout this lesson.
Adding your first link to a page
Let’s add a hyperlink to a basic HTML page.
Start with this structure:
Hyperlinks and Anchors
My First Link
Now add a paragraph with a link inside the body:
Visit how.dev to continue learning HTML.
Save the file and open it in your browser. You should see a clickable link. When you click it, the browser navigates to the specified website.
Linking to external websites
Links that point to other websites are called external links. These usually include the full URL, starting with https://.
Example:
External links are commonly used to reference resources, documentation, or related content outside your site.
When linking externally, it’s important to make link text clear and meaningful so users know where the link will take them.
Writing good link text
One of the most important habits you can build early is writing good link text.
Link text should describe the destination or purpose of the link. Avoid vague phrases like “click here” or “read more.”
For example, this is not ideal:
A better version would be:
This improves usability, accessibility, and clarity for all users.
Linking to pages within your site
Links don’t have to point to external websites. You can also link between pages on your own site.
This is done using relative paths, which refer to files in the same folder or directory.
For example, if you have two files:
index.htmlabout.html
You can link from one to the other like this:
When the user clicks the link, the browser loads the about.html file.
Step-by-step: creating internal links
Create a second file called about.html with this content:
About
About This Site
This page explains what the site is about.
Now, in your index.html, add this link:
Save both files and open index.html in your browser. Clicking the link should navigate to the About page.
This is one of the most important concepts in web development: pages connected through links.
Relative vs absolute URLs
An absolute URL includes the full web address, including the protocol and domain.
Example:
A relative URL points to a file relative to the current page’s location.
Example:
Relative URLs are commonly used for internal navigation because they make sites easier to move and deploy.
Opening links in a new tab
Sometimes you want a link to open in a new browser tab. This is done using the target attribute.
Example:
The value _blank tells the browser to open the link in a new tab.
Use this sparingly. Opening new tabs unexpectedly can be confusing for users. It’s usually best reserved for external links.
Adding link titles
You can add additional information to a link using the title attribute.
Example:
When users hover over the link, the title text appears as a tooltip. This can be helpful, but it should not replace clear link text.
Anchors within the same page
Links don’t always need to go to a different page. You can link to specific sections within the same page using anchor links.
This is useful for long pages, tables of contents, or “back to top” links.
To do this, you need two things:
- An element with an
id - A link that points to that
id
Step-by-step: linking to a section on the same page
First, add an id to a heading:
Contact Information
Now create a link that points to that section:
When the link is clicked, the browser scrolls to the element with the matching id.
Creating a table of contents
Anchor links are often used to create tables of contents for long pages.
Example:
Contents
Each link jumps to a different section of the page, improving navigation.
Email and phone links
Anchors can also be used to create email and phone links.
An email link looks like this:
A phone link looks like this:
When clicked, these links open the user’s email client or phone dialer.
Wrapping other elements with links
Links are not limited to text. You can wrap images or other elements inside anchor tags.
Example:
This makes the image clickable. This technique is commonly used for logos and banners.
Accessibility and links
Links play a major role in accessibility. Screen readers announce links and allow users to navigate between them.
This is why descriptive link text is so important. Screen reader users often browse links out of context.
Instead of hearing “click here,” they should hear something meaningful like “Learn HTML basics.”
Common beginner mistakes with links
One common mistake is forgetting to include the href attribute. Without it, the anchor tag won’t function as a link.
Another mistake is using vague or repeated link text, which makes navigation confusing.
Some beginners also misuse anchor links by forgetting to add matching id attributes.
Carefully checking your links is a good habit to build early.
Practice: building a navigation section
Add this to your HTML body to practice linking:
Save and refresh. Click each link to see how navigation works.
How links prepare you for real websites
Almost every real website relies heavily on links. Navigation menus, buttons, footers, and calls to action all use anchor tags behind the scenes.
Learning to create clean, meaningful links now makes building real sites much easier later.
What you should understand after this lesson
By now, you should be comfortable with:
- Creating links using the
<a>tag - Understanding the
hrefattribute - Linking to external and internal pages
- Using anchor links within a page
- Writing clear and accessible link text
You don’t need to master every variation yet. Focus on understanding how links connect content.
What’s next?
Now that you know how to connect pages and sections using hyperlinks, you’re ready to work with media.
In the next lesson, you’ll learn how to add images to your web pages and control how they appear using HTML.
Before moving on, try creating a small multi-page site with at least three pages connected using links. This simple exercise reinforces one of the most important ideas behind the web: everything is connected.
