remove grey background on link clicked in ios safari / chrome / firefox
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
On iOS, tapping a link often shows a gray translucent highlight. That effect comes from the browser’s tap feedback system, and many developers notice it first when a carefully styled button suddenly flashes a color they did not design.
The fix is usually straightforward: control the tap highlight with CSS. The important part is understanding what you are removing so you can replace it with accessible feedback if needed.
Why the Gray Overlay Appears
Safari, Chrome, and Firefox on iOS all run on WebKit, so they share much of the same touch behavior. When you tap a link or another interactive element, WebKit applies a highlight color to confirm that the tap was registered.
That visual feedback is controlled by the -webkit-tap-highlight-color property. By default, the browser chooses a translucent color that often appears gray or bluish depending on the page and system theme.
If your design already has a pressed state, this default overlay can look like a bug even though it is intentional browser behavior.
Removing the Tap Highlight
To remove the gray background, set the highlight color to transparent on the interactive elements you care about.
In many projects, applying that rule to anchors and custom button-like elements is enough.
If you want to scope the change to a specific component instead of the whole site, target that component class instead:
This is usually better than a global reset if only part of the interface needs custom interaction styling.
Add Your Own Pressed State
Removing the browser feedback entirely can make taps feel unresponsive, especially on slower pages. A better approach is often to remove the default overlay and provide your own active style.
This keeps interaction feedback while staying consistent with the rest of your design system.
What This Does Not Change
-webkit-tap-highlight-color only affects the tap highlight overlay. It does not remove:
- element outlines from keyboard focus
- background changes defined in your own
:activestyles - JavaScript touch event behavior
- selection or callout behavior
That distinction matters because developers sometimes disable the tap highlight and then assume the remaining flash must come from the browser too. Often it is actually a site-specific :active rule, focus style, or JavaScript class toggle.
Example with HTML
Here is a minimal example you can test on an iPhone or iPad:
If the gray overlay is still visible after this change, inspect whether the tap is landing on a child element that does not inherit the property or whether another style is creating the effect.
Accessibility and UX Tradeoffs
The browser highlight exists for a reason: it confirms user input. Removing it without replacement can make the interface feel less responsive and can reduce clarity for some users.
A good compromise is:
- disable the default tap highlight
- keep visible focus styles for keyboard and assistive technology users
- add a custom pressed state for touch interaction
That preserves both brand consistency and interaction clarity.
Common Pitfalls
One common mistake is setting outline: none instead of changing the tap highlight color. Those are separate behaviors, and removing focus outlines can create accessibility problems without fixing the iOS tap flash.
Another issue is applying the property only to a elements when the clickable area is actually a nested child or a custom element styled as a button. In that case, the tap feedback may still appear.
Developers also sometimes expect this property to work outside WebKit. The vendor prefix is a clue that the behavior is browser-engine-specific.
Finally, do not remove all feedback on interactive elements. If you suppress the default highlight, provide a deliberate :active or pressed style so the interface still feels responsive.
Summary
- The gray tap flash on iOS links is usually controlled by
-webkit-tap-highlight-color. - Safari, Chrome, and Firefox on iOS share this behavior because they use WebKit.
- Setting the highlight color to
transparentremoves the default overlay. - A custom
:activestyle is usually better than removing touch feedback entirely. - Focus outlines and tap highlights are different, so do not use
outline: noneas a substitute.
Related reading
- Remove HTML tags from a String
- Remove HTML Tags from an NSString on the iPhone
- Remove iOS input shadow
- Remove last item from array
- Remove last character from string. Swift language
- Remove or uninstall library previously added cocoapods
- Removing input background colour for Chrome autocomplete?
- Rendering Plaintext as HTML maintaining whitespace – without pre
.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.