Lesson 7 of 21 – HTML Links
35%
35%

HTML Links

Links are found in almost all web pages. HTML links allow users to click and jump from one page to another page, file, email, or location.

HTML links are created using the anchor tag: <a>

What Are HTML Links?

HTML links are also called hyperlinks. They help users move from one document to another. When you click a link, the browser opens the linked page or resource.

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

Breakdown of HTML Link

  • <a> : Anchor tag used to create a hyperlink.
  • href : Specifies the destination URL.
  • Link Text : The clickable text shown on the webpage.

Example

Example Link
<a href="https://www.soopropathshala.com">Visit Pathshala</a>

Opening Links in a New Tab

If you want a link to open in a new tab, use the target="_blank" attribute.

New Tab Example
<a href="https://www.google.com" target="_blank">Open Google</a>

Target Attribute Values

Value Description
_self Opens in the same tab or window
_blank Opens in a new tab or window
_parent Opens in the parent frame
_top Opens in the full body of the window

Other Useful Attributes for Links

rel

The rel attribute defines the relationship between the current document and the linked page. It is often used with target="_blank" for security.

<a href="https://example.com" target="_blank" rel="noopener noreferrer">Visit Website</a>
Email Link

HTML links can also open the user’s email client.

<a href="mailto:info@example.com">Send Email</a>
Phone Link

HTML links can also start a phone call on supported devices.

<a href="tel:+919999999999">Call Us</a>

Key Points

  • HTML links are created using the anchor tag <a>.
  • The href attribute specifies the URL of the page or resource.
  • The link text is the clickable part shown in the browser.
  • target="_blank" opens a link in a new tab.
  • rel="noopener noreferrer" improves security for external links.
  • Links can also open email clients and phone dialers.
πŸ’‘ Remember
Links connect webpages and make website navigation easy for users.

🧠 Quiz

Which attribute specifies the destination of a link?