Did you know you can send a SMS from HTML?

Week 204 was posted by Charanjit Chana on 2021-09-20.

Turns out you can do a lot more than just send emails using the <a> tag in HTML. Even the mailto functionality can be fairly complex, letting you specify what to populate the To, CC, BCC, subject and body of an email with.

tel:

If you use the tel: prefix for a link, you can prompt the user to confirm they want to call a number. These tags are really useful on the websites of businesses in particular. Think of a restaurant, you want to call and make a booking or an order. The number is there and if it's clickable it's a little less friction between the user and the restaurant. Gone are the days of having to copy and paste (digitally or manually), now you can click and get going.

<a href="tel:+447999999999">call me</a>

This example would attempt to call the number '07999999999', I prefixed the country code to avoid doubt but in reality you can specify it in whatever way makes the most sense to you.

sms:

The SMS protocol is quite similar to mailto: although support might vary depending on your OS. In theory you can specify multiple recipients and a body (like you can for emails) but iOS only supports the first number it encounters. If you specify a single recipient and a body, the body is appended to the number so it's best to keep it simple for the widest support.

<a href="sms:+447999999999">text me</a>

This would initiate the compose window in your SMS client to the number '07999999999'.

Support for third party apps

There are also protocols for a whole range of apps, you can see a pretty good list at beradrian's blog. Support will depend on your OS and the apps you have installed.


Tags: development, html


Tweet WhatsApp Keep Upvote Digg Tumblr Pin Blogger LinkedIn Skype LiveJournal Like