Skip to content
techsnow

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: 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

AttributeExamplePurpose
hrefhref="page.html"Where the link goes.
targettarget="_blank"Opens the link in a new tab.
downloaddownloadDownloads the file instead of opening it.
titletitle="Opens in new tab"Tooltip text on hover.
<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>