Email Link in HTML

HTML <a> (anchor) element provides a way to add email address to send an email. To add an email address, assign href "mailto: email address". Let us have a look at an example.

Send an email to us: contact@learnperday.com

<!DOCTYPE html>
<html>
    <head>
    </head>
    <body>
        Send an email to us: 
        <a class="native-style-link" href="mailto:contact@learnperday.com">
            contact@learnperday.com
        </a>
    </body>
</html>
                        

When you click on the email link, it will launch an email client like outlook. If you don't have an email client, it will not be possible for you to send an email by clicking on the email link.

Email Body

It is also possible to add a sample body and sample subject in the email link. You can use subject and body keywords of that. Please have a look at the following example.

Send an email to us with subject and body: contact@learnperday.com

<!DOCTYPE html>
<html>
    <head>
    </head>
    <body>
        Send an email to us with subject and body: 
        <a class="native-style-link" href="mailto:contact@learnperday.com?subject=query&body=This is query.">
            contact@learnperday.com
        </a>
    </body>
</html>
                        

When you click on example link, it will open email client with already written subject and body. You can edit it.

Nowadays, mobile phones are widely used to browse through the web. It will be very good if you can just open phone dialer by tapping on the phone number just like when you click on mail and mail client opens. It is possible by adding a phone link.
To add phone link, you have to assign href "tel: phonenumber".

This is an emergency number: 198

<!DOCTYPE html>
<html>
    <head>
    </head>
    <body>
        This is an emergency number: 
        <a href="tel:198">198</a>
    </body>
</html>
                        

Try clicking above example link in your mobile.

Drawbacks

It is very easy to add an email link but it can cause a spamming problem for your email account.
When you add an email link into your web page, there are some programs which can harvest the email address and send spam emails or sell it to someone.
There are some ways to let the user send an email to you.
You can create a form in which a user sends their email address and via some program, you will get it as a mail.

Conclusion

In this section, we have learned useful funda of the link. It will be very useful.
In next section, we will learn about head in HTML.