Gabriel Alejandro López López (Software Engineer)

Special links for our websites

- How to use regular <a> links for custom tasks as calls, sms or email?

Sometimes we need our links to do something else besides going to another http location. Perhaps we want to allow visitor to use other ways to interact with us using email, sms, a call, or others. Let’s se how to.

Email

Very easy! <a href="mailto:me@domain.com">Send me an email</a> will generate an anchor that, when clicked, will tell the browser to open the application in charge of handling email on your system.

More “complex” examples:

More details on RFC 6068 - The mailto URI Scheme.

SMS

A little different:

More details on RFC 5724 - URI Scheme for Global System for Mobile Communications Short Message Service (SMS).

Phone Calls

Same idea here:

More details on RFC 3966 - The tel URI for Telephone Numbers and in Section 8 is adviced to always enclose the phone number inside the <a> tag, so the correct way for previous example should be something like:

Call me at <a href="tel:+1-555-111-1111">1-555-111-1111<a>.

Locations

If you want the link to open a map in a certain location:

More details on RFC 5870 - A Uniform Resource Identifier for Geographic Locations.

Conclusion

In all cases is required that your device have a correct user agent to handle this URI schemes. In PC the tel, sms, and geo will normally not work. But in smartphone the potencial of this feature is amazing. Use it!