Hyperlinks are one of the most important features of the web. In HTML, hyperlinks are created using the <a> element, also called the anchor tag.
The general structure of a hyperlink is:
<a href="URL">Link Text</a>
- <a> is the anchor tag.
- href is the attribute that specifies the URL.
- Link Text is what the user clicks.
<a href="https://www.google.com">Visit Google</a>
This will create a clickable link labeled Visit Google that opens Google in the browser.
| Attribute | Purpose / Example |
|---|---|
| href | Specifies the URL of the link (required) |
| target | Specifies where to open the link (e.g., _blank for new tab) |
| title | Displays extra information when hovered |
| rel | Specifies the relationship between the current page and the linked page (e.g., nofollow) |
<a href="https://www.example.com" target="_blank" title="Go to Example">Visit Example</a>
You can also link to a specific section on the same page using an id:
<a href="#section1">Go to Section 1</a>
<h2 id="section1">Section 1</h2>
target="_blank" only for external linkstitle to provide extra contextHyperlinks are essential for navigation on the web. The <a> tag, combined with attributes like href and target, allows you to link to other pages, sections, or resources effectively.
Learning to use hyperlinks properly is a key step in creating professional and accessible web pages.