Quick Reach
The mailto attribute in HTML
In HTML hyperlinks, you can use mailto: in the href to enable users sending the email by using their already set up email program. For example in your website, you have a link “contact us”. When a user clicks on that link the outlook express or some other email program that is set up at user’s machine will be opened.
The mailto syntax
The syntax of the mailto in HTML link is:
<a href=”mailto:toaddress@email.com>Contact</a>
As it can be seen inside the href attribute of the a tag, you can place mailto: followed by “To” email address where you intend to send the email. You may also give the subject of the email after using the email address as shown in the second example of this tutorial.
Example of using mailto in link
The example below shows how to link an email address to a hyperlink by using the mailto.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
<html>
<head>
<title>HTML link / hyperlink demo</title>
</head>
<body>
<a href=“mailto:toaddress@email.com” target=“_top”>
Email example</a>
</body>
</html>
|
Where you will replace toaddress@email.com address to the actual email address where you want to receive the email.
Specify subject in the HTML mailto
The example below shows how to include subject as well in the mailto in HTML hyperlinks. That means when a user clicks that link, the email program like outlook will open in a new email mode with To and Subject fields already filled by the given information in mailto part of the link.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
<html>
<head>
<title>HTML link / hyperlink demo</title>
</head>
<body>
<a href=“mailto:toaddress@email.com?subject=Purpose is Inquiry” target=“_top”>
Contact for inquiry</a>
</body>
</html>
|
A final word about mailto HTML
These days you should use mailto hyperlink quite carefully, as spammers catch the given email address and start sending spammed emails. You can also use HTML email forms along with captcha (for security) to decrease spam factor.
Leave A Comment?