logo

The anchor tag (<a>) can be used not only to link web pages, but also to link email addresses and even make images clickable.


πŸ“§ Using <a> for Email Links

πŸ‘‰ Use the mailto: inside the href attribute. This opens the default email application (like Gmail, Outlook) when the user clicks the link.

Example:

<a href="mailto:teacher@example.com">Email the Teacher</a>
  • When clicked, it opens the email app with β€œteacher@example.com” in the β€œTo” field.

πŸ‘‰ You can even pre-fill subject and body like this:

<a
  href="mailto:teacher@example.com?subject=Doubt in Homework&body=Hello Sir, I have a question about..."
>
  Email with Subject
</a>

πŸ–Ό Using <a> with Images (Clickable Image Link)

πŸ‘‰ Instead of link text, you can place an image inside the <a> tag. That way, clicking the image will open the link.

Example:

<a href="https://www.cbse.gov.in">
  <img src="cbse-logo.png" alt="CBSE Logo" width="150" height="100" />
</a>
  • Here, clicking the CBSE logo image will take the user to the CBSE website.

βœ… Combining Both Concepts

πŸ‘‰ You can even use an image as a link to email!

Example:

<a href="mailto:teacher@example.com">
  <img src="email-icon.png" alt="Email Icon" width="50" height="50" />
</a>
  • Clicking the email icon image will open the email app to send an email.

πŸ“ Summary

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

  • Image as Link:

    <a href="URL"><img src="image.jpg" alt="Image" /></a>
    
  • Image as Email Link:

    <a href="mailto:address@example.com"><img src="icon.png" /></a>