


Khusboo Tayal
Links are a fundamental part of the web. They allow users to navigate between pages, jump within a document, or open external websites. In HTML, links are created using the <a> tag, also known as the anchor tag.
The anchor tag (<a>) is used to define hyperlinks in HTML. It can link to:
Basic Syntax:
<a href="URL">Link Text</a>
Example:
<a href="https://www.example.com">Visit Example</a>
1. External Links
Links that point to a different website.
<a href="https://www.google.com">Go to Google</a>
2. Internal Links
Links that navigate to another page within the same website.
<a href="/about.html">About Us</a>
3. Email Links
Links that open the user's default email client.
<a href="mailto:someone@example.com">Send Email</a>
4. Phone Links
Links that dial a number when clicked (mostly used on mobile).
<a href="tel:+1234567890">Call Us</a>
5. Download Links
Links that allow users to download a file.
<a href="files/sample.pdf" download>Download PDF</a>
To open a link in a new tab or window, use the target="_blank" attribute:
<a href="https://www.example.com" target="_blank">Open in New Tab</a>
Anchor links allow you to jump to a specific section within the same page or another page using an ID selector.
Step 1: Add an id to the target element
<h2 id="contact">Contact Us</h2>
Step 2: Link to that id
<a href="#contact">Go to Contact Section</a>
You can also link to an ID on another page like this:
<a href="about.html#team">Meet the Team</a>
Links can be styled using CSS pseudo-classes:
Example:
a {
color: blue;
text-decoration: none;
}
a:hover {
color: red;
text-decoration: underline;
}HTML links and anchors make your website interactive and navigable. Whether you’re guiding users to another page or helping them jump to a section, mastering the use of the <a> tag is crucial for any web developer.
Learn how to use AI to build, market and grow your business. Subscribe our newsletter to get AI tips, tools and prompts in your inbox to power your marketing, sales and business.
#html #htmlanchors #htmllinks #htmltutorial #learnhtml #hyperlinks #webdevelopment #htmlforbeginners