How do I remove the blue styling of telephone numbers on iPhone/iOS?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
When developing web applications or creating web content meant for iOS devices like the iPhone, developers often encounter the peculiar behavior of phone numbers being automatically detected and styled as tappable links in the Safari browser. This blue styling indicates an active link, and while convenient for users wishing to quickly dial a number directly from a web page, it may cause unwanted styling issues in certain web designs.
This article will walk you through the technical steps necessary to prevent iOS from styling phone numbers as links, ensuring your design remains consistent across all devices.
Understanding the Behavior
Safari on iOS automatically detects phone numbers in web pages and converts them into clickable links. This feature, known as "Data Detectors," is intended to enhance user experience by providing quick access to call functionality. However, this automatic conversion applies styling which may not align with your site's aesthetic, leading developers to seek ways to suppress it.
Disabling Automatic Conversion
To prevent iOS from automatically styling phone numbers, you can make use of the meta tag in HTML. This tag controls various aspects of how a web page is interpreted and displayed.
- Meta Tag: This is an HTML tag used to provide structured metadata about a webpage. It often manages how browsers and search engines interpret the page.
- Attribute
name: Here, it specifies the feature being controlled.format-detectionrefers to the ability of iOS to format specific types of data automatically. - Attribute
content: This dictates the behavior of the specified feature. Settingtelephone=notells iOS Safari not to format phone numbers as tappable links. - Selector
a[href^="tel:"]: Targets all anchor tags (``<a>``) where the href attribute begins with "tel:", indicating a telephone link. - Properties:
color: inherit;: Ensures the link takes on the color of its parent element, preserving the original text color.text-decoration: none;: Removes underlining, maintaining a consistent text appearance with non-link text.
Related reading
- How do I replace weak references when using ARC and targeting iOS 4.0?
- How do I resize the UIImage to reduce upload image size
- How do I rotate the Android emulator display?
- How do I rotate the Android emulator display?
- How do I run a terminal command in a Swift script? e.g. xcodebuild
- How do I run/test my Flutter app on a real device?
- How do I save a UIImage to a file?
- How do I scale a UIButton's imageView?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.