How to create mail and phone link in HTML ?
In this article, we are going through step by step process to create an HTML Mailto and call link. When a user clicks on the mailto link, it opens a default email client in the user’s system. You can make these types of clickable links easily with the anchor tag.
Mailto link: Users can easily contact website owners or anyone with the help of a mailto link. Mailto link redirects the user to the email client and creates the new mail, addressing the email in the mailto link. Furthermore, we can specify the subject and default body text inside the mailto link which saves the time of users.
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML course.
The following queries and parameters into the mailto link:
- mailto: It accepts the recipient’s email address.
- cc: It is an optional parameter. It accepts another email address that will receive the carbon copy.
- bcc: It is also an optional parameter. It accepts one or more email addresses that will receive the blind carbon copy.
- subject: In this parameter, you can assign a default subject of the mail.
- body: It allows you to set default body text. However, it is optional.
- ?: It is a first parameter delimiter.
- &: It allows you to separate more than one query.
<a href = "mailto:email@example.com"> </a>
Moreover, users can add default subjects to the mailto link. If users want to add a little bit more information like CC emails, BCC emails, and body text then we can do it easily. We have to add all queries after user email followed by a question mark. If users want to add multiple queries then they can use & operator to separate two queries.
<a href=”mailto:firstname.lastname@example.orgemail@example.comfirstname.lastname@example.org&subject=Mail to GeeksForGeeks&body=Demo email” target=”_blank”>Contact at GeeksForGeeks </a>
Call link: As we have added the mailto link, we can also add a call link using the HTML anchor tag. When a user clicks on the call link, it redirects the user to the default call app with the addressed phone number in the call link. So, users don’t need to dial the phone number and they can make calls directly by pressing the call button.
We can also add a country code before the phone number inside the link.
<a href="tel:+91123-456-7890"> call US </a>
Different call actions:
- tel – To redirect to a call app.
- callto – To open skype app.
- SMS – To send a Text message.
- fax – To send a fax.
<a href=”callto:+91123-456-7890″> call US </a>
<a href=”SMS:+91123-456-7890″> call US </a>
<a href=”fax:+91123-456-7890″> call US </a>