HTML Basic Tags
Anchor Tag
The <a> (anchor) tag creates a hyperlink: the thing that makes the web a web. Links can point to another website, another page on your site, a file, an email address, or a section of the same page.
Syntax:
<a href="URL">Link text</a><a href="https://techsnow.com">Visit TechSnow</a>The href attribute holds the destination. The text between the tags is what the user sees and clicks.
Absolute and relative links
<!-- absolute: the full address of another website -->
<a href="https://www.google.com">Google</a>
<!-- relative: a page in your own site -->
<a href="about.html">About us</a>
<a href="blog/first-post.html">My first post</a>
<a href="../index.html">Back to home</a>Useful attributes
| Attribute | Example | Purpose |
|---|---|---|
href | href="page.html" | Where the link goes. |
target | target="_blank" | Opens the link in a new tab. |
download | download | Downloads the file instead of opening it. |
title | title="Opens in new tab" | Tooltip text on hover. |
Email, phone and jump links
<a href="mailto:hello@techsnow.com">Email us</a>
<a href="tel:+923001234567">Call us</a>
<a href="#contact">Jump to the contact section</a>
...
<section id="contact">...</section>Downloading a file
<a href="notes/html-cheatsheet.pdf" download>Download the cheat sheet</a>