Creating Links in HTML
What is a Link in HTML?
Links (also called hyperlinks) in HTML allow users to navigate between different web pages, websites, or sections of the same page. Links are created using the <a> (anchor) tag.
📌 Key Points:
- ✔ <a> is used to create hyperlinks.
- ✔ href="URL" specifies the destination of the link.
- ✔ Links can open other web pages, files, email clients, or sections within a page.
Basic Syntax of an HTML Link
<a href="URL">Link Text</a>
Types of Links
- 1. Linking to Another Website (External Link)
- 2. Linking to Another Page in the Same Website (Internal Link)
- 3. Linking to a Section in the Same Page (Anchor Links)
Linking to Another Website (External Link)
<a href="https://www.wikipedia.org">Go to Wikipedia</a>
Linking to Another Page in the Same Website (Internal Link)
<a href="about.html">About Us</a>
Linking to a Section in the Same Page (Anchor Links)
<a href="#section2">Go to Section 2</a>
<h2 id="section2">Section 2</h2>
Opening Links in a New Tab (target="_blank")
<a href="https://www.infomax.org.in" target="_blank">INFOMAX</a>
Attributes of <a> Tag in HTML
Attribute | Description | Example |
---|---|---|
href | Specifies the destination URL of the link | <a href="https://www.google.com">Google</a> |
target | Specifies where to open the link | <a href="page.html" target="_blank">New Tab</a> |
name | Specifies the name of Link used as bookmark | <a name="top"></a> |
download | Allows users to download a file | <a href="file.pdf" download>Download PDF</a> |
title | Adds a tooltip on hover | <a href="demo.html" title="click to learn more">Read More</a> |