In HTML, you can create a link that opens the user’s default email program and automatically populates the “To” field with a specified email address using the <a> (anchor) element and the “mailto:” protocol. Here’s an example:
In this example, the link text is “Send us an email” and the href attribute includes the “mailto:” protocol followed by the email address that the email should be sent to.
You can also add additional attributes to the <a> element to pre-fill the email subject or body. Here’s an example:
In this example, the href attribute includes the “mailto:” protocol followed by the email address, as well as the subject and body attributes to pre-fill the email subject and body text.
It’s important to note that not all users have a default email program set up on their device, so it’s a good idea to also provide a visible email address for users who may not be able to use the mailto link. Additionally, you should avoid using generic link text such as “click here” or “email us”, and instead use descriptive text that accurately describes the action that the link will perform.
Subject and Body Parameters:
You can customize the email link further by including subject and body parameters. This allows you to pre-fill the subject line and body of the email.
<a href="mailto:info@example.com?subject=Inquiry&body=Hello%20there,">Send an Inquiry</a>
Multiple Recipients:
You can include multiple email addresses by separating them with commas in the mailto
link.
<a href="mailto:info@example.com,john.doe@example.com">Send to Multiple Recipients</a>
CC and BCC:
You can also include CC (Carbon Copy) and BCC (Blind Carbon Copy) recipients by using the cc
and bcc
parameters.
<a href="mailto:info@example.com?cc=john.doe@example.com&bcc=jane.smith@example.com">Send with CC and BCC</a>
Styling with CSS:
Apply CSS styles to your email links to make them visually appealing and consistent with your website’s design.
<style>
a.email-link {
color: #007bff; /* Blue color */
text-decoration: none;
font-weight: bold;
}
</style>
<a href="mailto:info@example.com" class="email-link">Send an Email</a>
Icon Integration:
Enhance your email links by adding icons to make them more noticeable. You can use icon fonts or inline SVG for this purpose.
<a href="mailto:info@example.com">
<img src="email-icon.png" alt="Email Icon"> Send an Email
</a>
Obfuscation:
To mitigate email harvesting by bots, consider obfuscating the email address by using JavaScript or tools designed for this purpose.
<script type="text/javascript">
document.write('<a href="mailto:' + ['info', 'example.com'].join('@') + '">Send an Email</a>');
</script>
Encoding:
If you include special characters in the email address, ensure proper encoding to prevent issues with the link.
<a href="mailto:info%40example.com">Send an Email</a>
UTM Parameters:
If you’re using analytics tools, consider adding UTM parameters to track email link clicks in your web analytics platform.
<a href="mailto:info@example.com?utm_source=website&utm_medium=email-link">Send an Email</a>
Event Tracking:
Ensure that the text within the email link provides clear and meaningful information about the action. This is crucial for users relying on screen readers.
<a href="mailto:info@example.com">Contact Us</a>
Subject and Body Parameters:
You can customize the email link further by including subject and body parameters. This allows you to pre-fill the subject line and body of the email.
<a href="mailto:info@example.com?subject=Inquiry&body=Hello%20there,">Send an Inquiry</a>
Multiple Recipients:
You can include multiple email addresses by separating them with commas in the mailto
link.
<a href="mailto:info@example.com,john.doe@example.com">Send to Multiple Recipients</a>
CC and BCC:
You can also include CC (Carbon Copy) and BCC (Blind Carbon Copy) recipients by using the cc
and bcc
parameters.
<a href="mailto:info@example.com?cc=john.doe@example.com&bcc=jane.smith@example.com">Send with CC and BCC</a>
Styling with CSS:
Apply CSS styles to your email links to make them visually appealing and consistent with your website’s design.
<style>
a.email-link {
color: #007bff; /* Blue color */
text-decoration: none;
font-weight: bold;
}
</style>
<a href="mailto:info@example.com" class="email-link">Send an Email</a>
Icon Integration:
Enhance your email links by adding icons to make them more noticeable. You can use icon fonts or inline SVG for this purpose.
<a href="mailto:info@example.com">
<img src="email-icon.png" alt="Email Icon"> Send an Email
</a>
Obfuscation:
To mitigate email harvesting by bots, consider obfuscating the email address by using JavaScript or tools designed for this purpose.
<script type="text/javascript">
document.write('<a href="mailto:' + ['info', 'example.com'].join('@') + '">Send an Email</a>');
</script>
Encoding:
If you include special characters in the email address, ensure proper encoding to prevent issues with the link.
<a href="mailto:info%40example.com">Send an Email</a>
UTM Parameters:
If you’re using analytics tools, consider adding UTM parameters to track email link clicks in your web analytics platform.
<a href="mailto:info@example.com?utm_source=website&utm_medium=email-link">Send an Email</a>
Event Tracking:
Ensure that the text within the email link provides clear and meaningful information about the action. This is crucial for users relying on screen readers.
<a href="mailto:info@example.com">Contact Us</a>
Learners TV is a website that is designed to educate users and provide instructional material on particular subjects and topics.