How to trigger a phone call when clicking a link in a web page on mobile phone
The tel:
protocol used within an anchor (<a>
) tag constructs a clickable phone link: <a href="tel:+1234567890">Call Us</a>
. Replace +1234567890
with the designated phone number, which must include the +
sign and country code. A tap on this link in a mobile device immediately initiates a call.
Example:
This approach is straightforward, effective, and universally supported across mobile browsers.
Implementing tel:
links for different devices
Displaying on mobile devices only
The mobile browser world is an ideal landscape for tel:
links. Use this CSS snippet to only show these links on mobile devices:
Use the class .desktop-tel-link
for your tel:
links.
Handling desktop environments
Although ineffective on many desktop environments, a few may prompt to open VoIP applications:
Formatting international and local numbers
Use the international dialing format for wider reach, but for numbers local to the user, consider this approach:
Enhancing user interaction with tel:
links
Providing visual cues
Integrate the tel:
link within a button or icon to create an appealing and intuitive interface:
Auto-detection on iOS devices
Apple's Safari browser can auto-detect numbers, but the tel:
prefix ensures consistency.
Promoting accessibility
Test with various assistive technologies to ensure all users can interact with your function. Incorporate suitable alt
tags and ensure the links can be navigated using keyboard commands or voice instructions.
Creative usage of tel:
links
Images as your call buttons
Transform images into call buttons to provide a dazzling user experience.
Styling your call links
Style your tel:
links to stand out from or blend in with your website's aesthetic.
Practical considerations and best practices
Respect for security and privacy
Sanitize those numbers to prevent injection attacks. Remeber to keep your tel:
link clicks private, unless you absolutely need to track them.
Usability is key
Place tel:
links where users would expect them, like the footer or near contact information.
Testing, the secret to success
Don't forget to test your links across different devices and browsers before you release them into the wild.
Why tel:
and not callto:
?
The tel:
protocol is the proven standard to initiate phone calls via hyperlinks. The callto:
protocol finds less consistency across devices and focuses on Skype, which is not a universal manner of communication.
Was this article helpful?