Skip to main content

Command Palette

Search for a command to run...

HTML Links (`<a>` Tag): How to Create Links in HTML

Updated
3 min read
M
Hi, I'm Subhash Singh, a Computer Science student passionate about web development, programming, and technology. I share simple and beginner-friendly content to help others learn and grow.

Introduction

Links are one of the most important parts of any website. They allow users to move from one page to another or visit external websites. In HTML, links are created using the <a> (anchor) tag.

In this article, you'll learn how to use the <a> tag, its attributes, and different types of links with simple examples.


What is the <a> Tag?

The <a> tag is used to create hyperlinks in HTML.

Example

<a href="https://www.google.com">Visit Google</a>

Output:

Visit Google


Syntax

<a href="URL">Link Text</a>
  • href specifies the destination URL.
  • Link Text is the clickable text visible to users.

Linking to Another Website

<a href="https://www.github.com">
  Visit GitHub
</a>

When clicked, this link opens GitHub.


<a href="https://www.google.com" target="_blank">
  Open Google
</a>

The target="_blank" attribute opens the link in a new browser tab.


Linking to Another Page

<a href="about.html">
  About Us
</a>

This is called an internal link because it connects pages within the same website.


<a href="mailto:example@gmail.com">
  Send Email
</a>

Clicking this link opens the user's default email application.


<a href="tel:+911234567890">
  Call Now
</a>

This is especially useful for mobile websites.


  • Connect different web pages
  • Improve website navigation
  • Help users find information quickly
  • Support SEO
  • Make websites interactive

Best Practices

  • Use meaningful link text.
  • Avoid using "Click Here" everywhere.
  • Open external links in a new tab only when necessary.
  • Always test your links before publishing.

Conclusion

The <a> tag is one of the most commonly used HTML elements. Learning how to create links correctly will help you build professional, user-friendly, and well-structured websites.


Frequently Asked Questions (FAQs)

1. What does the <a> tag do?

It creates hyperlinks in HTML.

2. What is the href attribute?

The href attribute specifies the destination URL where the link will take the user.

Use the target="_blank" attribute.

Example:

<a href="https://www.google.com" target="_blank">
  Open Google
</a>

Yes. You can use a relative path like:

<a href="about.html">About Us</a>

Final Thoughts

Understanding HTML links is an essential step in web development. Once you master the <a> tag, you'll be able to connect pages, create navigation menus, and build complete websites with ease.