Telephone Link Protocol

By  on  

We've always been able to create links with protocols other than the usual HTTP, like mailto, skype, irc ,and more;  they're an excellent convenience to visitors.  With mobile phone browsers having become infinitely more usable, we can now extend that convenience to phone numbers:

The tel protocol is used for phone numbers:

<a href="tel:18008675309">Call Jenny!</a>

If you'd like to create a link for SMS text messaging, that's easy enough too:

<a href="sms:18008675309">Text Jenny!</a>

The sms protocol is used for text.

Many mobile browsers automatically linkify phone numbers on webpages but with the snippet above you can forcibly create phone links!  Since said links don't work on desktop browsers, it's probably wise to create a JS snippet to replace spans with a given CSS class with phone links.

Recent Features

  • By
    Responsive Images: The Ultimate Guide

    Chances are that any Web designers using our Ghostlab browser testing app, which allows seamless testing across all devices simultaneously, will have worked with responsive design in some shape or form. And as today's websites and devices become ever more varied, a plethora of responsive images...

  • By
    5 HTML5 APIs You Didn&#8217;t Know Existed

    When you say or read "HTML5", you half expect exotic dancers and unicorns to walk into the room to the tune of "I'm Sexy and I Know It."  Can you blame us though?  We watched the fundamental APIs stagnate for so long that a basic feature...

Incredible Demos

  • By
    AJAX For Evil:  Spyjax with jQuery

    Last year I wrote a popular post titled AJAX For Evil: Spyjax when I described a technique called "Spyjax": Spyjax, as I know it, is taking information from the user's computer for your own use — specifically their browsing habits. By using CSS and JavaScript, I...

  • By
    Duplicate the jQuery Homepage Tooltips Using Dojo

    The jQuery homepage has a pretty suave tooltip-like effect as seen below: Here's how to accomplish this same effect using Dojo. The XHTML The above HTML was taken directly from the jQuery homepage -- no changes. The CSS The above CSS has been slightly modified to match the CSS rules already...

Discussion

  1. John Holt Ripley

    I’ve not yet found a way to detect support for this protocol, other than UA detection – are you aware of a way to do it?

    • As of 2018, both of these protocols are well supported by all the major browsers & As far as the auto link conversion is concerned, you can use a meta tag to disable it

  2. Stuart

    “Since said links don’t work on desktop browsers, it’s probably wise to create a JS snippet to replace spans with a given CSS class with phone links.”

    Ugh. That deprives desktop browsers, desktop browser add-ons, and other unknown browsers of the semantic information that they could use to do something useful with those links. Gmail supports sending text messages, for example – so a desktop browser add-on that does something clever with sms: protocol links to open up an appropriate gmail chat window would be perfectly possible… unless the web page decided not to bother sending sms: links to desktop browsers. Pretty sure there are web telephony apps for desktop computers that support making voice calls to phone numbers, as well.

    In an ideal world (in my opinion) browser makers would be responsible for doing something sensible with links that they can’t resolve due to unsupported protocols – for example, it’d make sense to stylistically grey them out, add a tooltip indicating the functionality is unavailable, and offer a CSS pseudoclass and something in javascript to enable web authors to detect the situation and react accordingly.

    I don’t know what to do in a world where browsers are unintelligent about invalid protocols, but I hate the idea of penalizing (future?) browsers and/or add-ons that ARE smart in order to protect current browsers that aren’t.

  3. Dan

    Stuart: That makes sense, maybe a pseudo-selector like ::unsupported-protocol.

    But yeah in Chrome tel: and sms: links don’t seem to do anything at all (I would expect at least an error dialog) but I suspect Skype would register at least one of those, and Google Voice would be a perfect candidate to register handlers for both.

  4. AV

    It can be a security problem. On many phones with phone numbers you can do many low level things like format the phone. A few months ago that appeared on news, and the standard android browser was vulnerable, opera mobile instead showed a security warning before launching the dialer. I don’t know about firefox.

  5. bert

    “Since said links don’t work on desktop browsers”

    I could see where the tel protocol could potentially be used to initiate a call on your desktop providing you had an installed softphone with a SIP account that had POTS termination.

  6. Chase

    I’ve worked on this a bit, and came up with a solution that for me has worked 99% (leave some room for error). It’s a pure js solution, and the source code describes the approach.

    http://stackoverflow.com/a/13675901/124069

  7. jenski

    Skype picks up on telephone-like numbers regardless of the tel: protocol, as far as I know.
    Didn’t knew about the sms thing tho. tnx!

  8. Aurélien

    Hi, Thanks for sharing.

    Is there a way to add preformatted text for a SMS ?

    Example :
    Send to 18008675309 the text “Hi, Please call me back.”

  9. Figmo

    “Since said links don’t work on desktop browsers…”

    Why shouldn’t they?

    I found this page searching for an add-on that would allow my desktop browser to dial phone numbers for me.

    Why is it that the whole world assumes just because you’re at your desk that you wouldn’t find it convenient to automatically dial the number for some business you just did a search for.

  10. Mike

    We have an Avaya phone system connected to desktop PCs. We have dial button on client apps but I need to do it from a custom web app. I guess Avaya has an API. Anyone done anything like this?

  11. michael

    i want dial desktop phone (avaya) by clicking an image on web page on a desktop pc connected to a phone.

  12. KAC

    try your code in mozilla bud…

  13. Brian Gateley

    Anyone know how to include * codes in a TEL link? Something like href='tel://*6718008675309' apparently is an invalid link, at least according to my Nextiva app.

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!