D Dev Notebook

HTML5 Hyperlinks

HTML

What is a Hyperlink?

A hyperlink (or simply "link") allows users to click and navigate from one page to another, to another location on the same page, or to resources like images, PDFs, downloads, etc.

Hyperlinks in HTML are created using the <a> (anchor) tag.

<a href="URL">Link Text</a>

  • <a>: The anchor element that creates the hyperlink.
  • href: The attribute that specifies the destination URL.

When clicked, it will take the user to Visit Google.

Types of Hyperlinks

1. Absolute URL

Links to an external website.

Go to Google

2. Relative URL

Links to another page within the same website.

About Us

3. Link to an Email

Using mailto: to open the default mail client.

Send Email

4. Link to a Phone Number

Using tel: to start a call on mobile devices.

Call Us

5. Link to a Section on the Same Page (Anchor)

Go to Contact Section


Attributes of <a>

Download PDF

AttributeDescription
hrefURL to navigate to
targetDefines where to open the link (_blank for new tab, _self for same tab)
titleTooltip text when you hover over the link
downloadTells browser to download the linked file instead of navigating to it