HTML Links


🔹 What are HTML Links?

HTML links (or hyperlinks) allow users to navigate from one page to another, either within the same site or to an external site. Links are created using the <a> (anchor) tag.


🔹 Basic Syntax
<a href="URL">Link Text</a>
  • href: The attribute that holds the destination URL.

  • Link Text: The clickable text shown to the user.


🔹 Example: Link to Google
<a href="https://www.google.com">Visit Google</a>

🔹 Types of Links

Type Example
External Link <a href="https://example.com">Go to site</a>
Internal Link <a href="about.html">About Us</a>
Email Link <a href="mailto:info@example.com">Email Us</a>
Telephone Link <a href="tel:+911234567890">Call Now</a>
Anchor Link <a href="#section2">Go to Section 2</a> (on same page)

🔹 Open Link in New Tab

Use the target="_blank" attribute:

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

🔹 Link Titles (Tooltip)

<a href="https://example.com" title="Visit Example Site">Visit</a>

When hovered, the user sees a tooltip.


🔹 Link with Image

<a href="https://example.com">
  <img src="logo.png" alt="Site Logo">
</a>

🔹 Link Colors and Styling

By default:

  • Unvisited link = blue

  • Visited link = purple

  • Active link = red

You can change these styles using CSS.

<style>
  a {
    color: green;
    text-decoration: none;
  }
</style>

Practice Questions

Q1. Create a link to https://www.google.com.

Q2. Add a link that opens in a new tab.

Q3. Make an internal link to a file named contact.html.

Q4. Add a mailto: link to send an email.

Q5. Create a link that opens the dialer with a phone number.

Q6. Use #footer to link to a section at the bottom of the same page.

Q7. Add a title to a link that says “Go to Home Page”.

Q8. Create an image link using your logo.

Q9. Change link color to green and remove underline using CSS.

Q10. Create a navigation menu using multiple <a> tags.


Go Back Top