View All HTML Tutorials

How to Make Hyperlinks Using HTML

Hyperlinks are one of the most important parts of the web. They let users move from one page to another, open documents, visit external websites, send emails, or jump to a different...

HTML hyperlinks tutorial illustration

Introduction

Hyperlinks are one of the most important parts of the web. They let users move from one page to another, open documents, visit external websites, send emails, or jump to a different part of the same page.

In HTML, hyperlinks are created using the <a> element. The letter “a” stands for “anchor”.

A simple hyperlink looks like this:

HTML
<a href=”https://www.example.com”>Visit Example</a>

This creates a clickable link that says:

Visit Example

The href attribute tells the browser where the link should go. The text between the opening <a> tag and the closing </a> tag is the clickable text the user sees.

Here is the same example again:

HTML
<a href=”https://www.example.com”>Visit Example</a>

It has three main parts:

HTML
<a>

This opens the anchor element.

HTML
href=”https://www.example.com”

This tells the browser the destination of the link.

HTML
Visit Example

This is the visible link text.

HTML
</a>

This closes the anchor element.

Linking to Another Website

To link to another website, use the full web address, including https://.

HTML
<a href=”https://www.google.com”>Go to Google</a>

This is called an external link because it goes to a different website.

Linking to Another Page on Your Own Website

You can also link to another page in the same website.

For example, if you have a page called about.html, you can link to it like this:

HTML
<a href=”about.html”>About Us</a>

If the page is inside a folder, include the folder name:

HTML
<a href=”pages/contact.html”>Contact Us</a>

This type of link is called an internal link.

Sometimes you may want a link to open in a new browser tab. To do this, add target="_blank".

HTML
<a href=”https://www.example.com” target=”_blank”>Open Example in a New Tab</a>

When using target="_blank", it is good practice to also add rel="noopener noreferrer" for security and privacy reasons.

HTML
<a href=”https://www.example.com” target=”_blank” rel=”noopener noreferrer”>  Open Example in a New Tab</a>

You can make a link that opens the user’s email app by using mailto:.

HTML
<a href=”mailto:[email protected]”>Email Us</a>

When the user clicks the link, their email program will open with the email address already filled in.

You can also add a subject line:

HTML
<a href=”mailto:[email protected]?subject=Website enquiry”>Email Us</a>

On mobile devices, you can create a link that lets users call a phone number.

HTML
<a href=”tel:+441234567890″>Call Us</a>

This is useful for business websites, contact pages, and mobile-friendly designs.

Linking to a Section on the Same Page

You can create a link that jumps to a specific section of the same page.

First, give the target section an id:

HTML
<h2 id=”contact”>Contact Information</h2>

Then create a link to that section using # followed by the ID name:

HTML
<a href=”#contact”>Go to Contact Information</a>

When clicked, the browser will jump to the section with the matching id.

Linking to a File

You can also link to files, such as PDFs, images, or documents.

HTML
<a href=”files/guide.pdf”>Download the Guide</a>

Depending on the browser and file type, the file may open in the browser or download to the user’s device.

Good link text should explain where the link goes. Avoid vague phrases like:

HTML
<a href=”about.html”>Click here</a>

A better version would be:

HTML
<a href=”about.html”>Learn more about our company</a>

Clear link text is better for accessibility, search engines, and user experience.

Adding a Title Attribute

You can add a title attribute to give extra information about a link.

HTML
<a href=”services.html” title=”View our full list of services”>Our Services</a>

When some users hover over the link, the title text may appear as a small tooltip. However, do not rely on the title attribute for important information because it is not always accessible on mobile devices or screen readers.

By default, links are usually blue and underlined. You can change their appearance with CSS.

HTML
<a href=”about.html” class=”button-link”>About Us</a>
CSS
.button-link {  color: white;  background-color: blue;  padding: 10px 15px;  text-decoration: none;  border-radius: 5px;}

This can make a link look more like a button.

You can also style links when the user hovers over them:

CSS
.button-link:hover {  background-color: darkblue;}

A Complete Example

Here is a simple HTML page with different types of links:

HTML
<!DOCTYPE html><html lang=”en”><head>  <meta charset=”UTF-8″>  <title>HTML Links Example</title></head><body>   <h1>HTML Hyperlinks</h1>   <p>    <a href=”https://www.example.com”>Visit Example</a>  </p>   <p>    <a href=”about.html”>About Us</a>  </p>   <p>    <a href=”mailto:[email protected]”>Email Us</a>  </p>   <p>    <a href=”#contact”>Jump to Contact Section</a>  </p>   <h2 id=”contact”>Contact Section</h2>  <p>This is the contact section of the page.</p> </body></html>

Common Mistakes to Avoid

One common mistake is forgetting to include the href attribute.

Incorrect:

HTML
<a>Visit our page</a>

Correct:

HTML
<a href=”page.html”>Visit our page</a>

Another common mistake is forgetting the closing </a> tag.

Incorrect:

HTML
<a href=”about.html”>About Us

Correct:

HTML
<a href=”about.html”>About Us</a>

You should also avoid using unclear link text such as “click here” or “read more” when more descriptive text would be better.

Summary

Hyperlinks are made in HTML using the <a> element. The most important attribute is href, which tells the browser where the link should go.

The basic pattern is:

HTML
<a href=”destination”>Link text</a>

You can use hyperlinks to link to websites, pages, files, email addresses, phone numbers, and sections within the same page.

Once you understand the <a> element, you have learned one of the core building blocks of the web.