Learn HTML – Part 5 – Anchor Tag – Creating Links in HTML
The HTML a tag, also called the anchor tag, is used to create links between web pages.
Links allow users to navigate from one page to another, making them one of the most important elements of the web.
What is the Anchor Tag?
The a tag defines a hyperlink that connects one page to another page, section, or resource.
When users click a link, the browser navigates to the specified location.
Basic Syntax
<a href="https://example.com">Visit Website</a>
Here:
adefines the hyperlinkhrefspecifies the destination URL- The text between the tags becomes the clickable link
Example – Creating a Simple Link
<a href="https://google.com">Go to Google</a>
Output:
Opening Links in a New Tab
You can open a link in a new browser tab using the target attribute.
<a href="https://example.com" target="_blank">Open Website</a>
_blankopens the link in a new tab_selfopens in the same tab (default)
Linking to Another Page
You can also link to another page within the same website.
<a href="about.html">About Us</a>
This is called an internal link.
Types of Links
| Type | Description |
|---|---|
| External Link | Links to another website |
| Internal Link | Links to another page in the same site |
| Email Link | Opens the user’s email application |
| Anchor Link | Links to a specific section of a page |
Email Link Example
<a href="mailto:info@example.com">Send Email</a>
Common Mistakes Beginners Make
- Forgetting the
hrefattribute - Using incorrect URLs
- Opening too many links in new tabs unnecessarily
Links are the backbone of the internet — they connect web pages together.
Conclusion
The HTML a tag is used to create hyperlinks that connect web pages and resources.
It plays a crucial role in website navigation and allows users to move between pages easily.
What’s Next?
Now that you understand the anchor tag, the next step is learning about the img tag, which is used to display images on a webpage.
Next: Learn HTML – Part 6 – Image Tag – Displaying Images in HTML →
Series: Learn HTML Series
