How to mark-up phone numbers?
To add a clickable phone number in your webpage, use the <a>
tag with a href
attribute that includes the tel:
protocol:
The phone number in href should adhere to the E.164 international format (+1234567890
), but you can format the visible text in a more readable way. For increased accessibility, use an aria-label
to make it friendly for screen readers:
Congrats, you've just crafted an accessible and ergonomic phone link!
Managing cross-device compatibility
While the tel:
protocol works great on mobile devices, the story can be a bit more complex when we venture into the desktop universe.
Avoid nonstandard links
Early attempts to create clickable phone numbers resulted in the now-obsolete callto:
protocol. To guarantee a smooth user experience, stick to tel:
which is well supported by modern VoIP applications like Skype and Microsoft Teams in browsers such as Chrome.
Emergency numbers: Handle with care
Remember that tel:
links may cover routine calls, but emergency services have specific rules. Posting a disclaimer or providing alternative dialing instructions for emergency numbers like 911 or 112 might save a life!
Creating alternative routes for desktop users
A quick JavaScript function can swap out tel:
links for the traditional callto:
when a desktop environment is detected, ensuring wider coverage while abiding by the standards.
Addressing "real world" scenarios
Detecting user environment
Being aware of your visitor's device or browser can help in customizing their experience. GoatCounter wrote a handy blog on using JavaScript to detect mobile browsers and adjust tel:
link behavior accordingly.
Cross-browser tricks and treats
tel:
URI support varies by browser. While Chrome and Safari give a thumbs-up, Firefox and Internet Explorer display an array of quirks. Prepare a fallback plan for these outliers.
Evolution of software support
Once upon a time, Skype only recognized callto:
. But time and user preferences encouraged it to embrace tel:
. Staying up-to-date with VoIP software developments can help prevent unanticipated support issues.
Teaching users to fish
Educate about browser-specific behavior and offer an easy-to-reach Help Center. A short prompt to guide the user when a tel:
link doesn't work as expected is a great fallback:
References
Was this article helpful?