Courses
Help
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>