header-logo

CODE WITH FAHIM

HTML Links

🔗 What are HTML Links?

HTML links, or **hyperlinks**, are one of the most fundamental components of the web. They allow users to navigate between pages on a website or jump to completely different websites.

HTML uses the anchor tag `` to create a hyperlink.

The Anchor Tag `
`

The anchor tag `
` is used to define a hyperlink. The most important attribute of the `` tag is `href`, which specifies the destination address (URL) of the link.

**General Syntax:**
<a href="url">link text</a>

Attributes of <a> tag
The `
` tag supports several important attributes that modify the link's behavior:

The `target` Attribute

The `target` attribute specifies where to open the linked document. The following values are supported:
Value Description
`_self` **Default.** Opens the document in the same window/tab where it was clicked.
`_blank` Opens the document in a new window or tab.
`_parent` Opens the document in the parent frame.
`_top` Opens the document in the full body of the window.

Example of External Link
This link will open Google's homepage in a new browser tab:
<a href="https://www.google.com" target="_blank">Visit Google</a>

**Result:**
Visit Google

Creating a Download Link

To make a link force a download of the target file instead of navigating to it, use the `download` attribute.
<a href="images/my-image.jpg" download>Download Image</a>


Link to an Email Address (Mailto)

You can use `mailto:` in the `href` attribute to create a link that automatically opens the user's email client, allowing them to send an email to a specified address.
<a href="mailto:support@example.com">Email Us</a>