Making Phone Numbers Clickable
In modern web development, providing a seamless user experience on mobile devices is crucial. A key part of this is allowing users to easily initiate phone calls directly from your website or web application. This is achieved by leveraging the tel:
URI scheme in HTML. This tutorial will guide you through the correct formatting and best practices for creating clickable phone numbers.
The tel:
URI Scheme
The tel:
URI scheme is a standard way to indicate a telephone number within a URL. When a user clicks a link with a tel:
URI on a mobile device, the device will prompt the user to either initiate a call or add the number to their contacts.
Basic Implementation
The fundamental structure of a clickable phone number link is as follows:
<a href="tel:+15551234567">Call Us</a>
Replace +15551234567
with the complete phone number you wish to make clickable. Note the use of the plus sign (+
) at the beginning. This signifies the international dialing prefix, which is essential for proper dialing behavior.
International Phone Number Formatting
The most crucial aspect of creating clickable phone numbers is correct international formatting. Here’s a breakdown:
- Country Code: Begin with the plus sign (
+
) followed by the country code. For example, the United States is+1
, the United Kingdom is+44
, and Germany is+49
. - Area Code/City Code: Follow the country code with the area or city code without any leading zeros. For instance, within the United States, a number might be
+12125551212
. Within Germany it might be+49301234567
. - Local Number: Append the remaining digits of the phone number.
Example: To make a German number clickable:
<a href="tel:+49301234567">Call Our Berlin Office</a>
Important Note: It’s generally best practice to remove any leading zeros from area or city codes when formatting international phone numbers.
Handling Extensions and Pauses
Sometimes, you need to dial an extension after reaching a phone number. The tel:
scheme offers ways to handle this:
-
Semicolon (
;
) for Wait/Pause: A semicolon introduces a pause in the dialing sequence. This allows the system to wait for a prompt before dialing the extension.<a href="tel:+15551234567;123">Call Support (Extension 123)</a>
-
Comma (
,
) for Short Pause: A comma can introduce a short pause before dialing the next digits.<a href="tel:+15551234567,123">Call Sales, then enter Extension 123</a>
Mobile Browser Considerations
Most modern mobile browsers (iOS Safari, Android Chrome, etc.) automatically detect phone numbers on a webpage and convert them into clickable links, even without the <a>
tag. However, explicitly creating the link with the tel:
scheme is the most reliable and cross-platform approach.
If you want to prevent automatic phone number detection (e.g., if you are displaying phone numbers that shouldn’t be clickable), you can use meta tags:
- For Safari (iOS):
<meta name="format-detection" content="telephone=no">
- For BlackBerry:
<meta http-equiv="x-rim-auto-match" content="none">
Best Practices
- Always use the
+
sign to indicate an international number. - Remove leading zeros from area/city codes.
- Test on multiple devices to ensure compatibility.
- Consider user experience: Clearly label the link (e.g., "Call Us", "Contact Support").
- Be mindful of privacy: Obtain user consent before collecting or displaying phone numbers.