HTML <a> Tag Tutorial
The HTML <a> tag is used to create links to other web pages, files, email addresses, or other resources. It stands for "anchor" because it creates a link that allows users to "anchor" to another location.
How It Works
To create a link using the <a> tag, you need to specify the href
attribute, which contains the URL of the page or resource you want to link to. You can also add additional attributes like target
to open the link in a new window or tab, title
for a tooltip, and more.
Main Tag Attributes
Attribute | Description |
---|---|
href | The URL of the page or resource to link to. |
target | Specifies where to open the linked document (e.g., "_self", "_blank"). |
title | Specifies a title or tooltip for the link. |
rel | Specifies the relationship between the current document and the linked document. |
Examples
Here's an example of a simple link:
<a href="https://www.example.com">Visit Example Website</a>
Here's an example of a link that opens in a new tab:
<a href="https://www.example.com" target="_blank">Visit Example Website</a>
Here's an example of a link with a tooltip:
<a href="https://www.example.com" title="Click here to visit Example Website">Visit Example Website</a>
And here's an example of a link with a specific relationship:
<a href="https://www.example.com" rel="nofollow">Visit Example Website</a>