Hover Stuck on Mobile After Tap? The (hover: hover) Fix

October 8, 2026  |  8 min read  |  CSS

By Syed · Frontend Engineer & Creator of UITweak

Tap a button on your phone. The hover style applies and never leaves. Tap another button and now two of them glow. The button is not broken and your CSS is not wrong: mobile browsers fake a hover on tap for compatibility with the desktop-era web, and since there is no mouse to move away, the fake hover sticks until something else takes focus. The fix is one media query, but it has to be the right one, applied in the right place.

30-second version: wrap every :hover rule that is decoration-only in @media (hover: hover) and (pointer: fine). Touch devices skip the block entirely, so nothing sticks. Give touch users :active press feedback instead, and kill the gray tap flash with -webkit-tap-highlight-color. Supported everywhere for a decade, no fallback needed.

Reproduce It First (Know What You Are Fixing)

Open any page with a :hover background change on your phone, tap the element, then tap empty space. The hover style stays. What happened: the tap fired mouseenter compatibility events, the browser applied :hover, and with no cursor to leave, the state persists. This is not a bug in your code; it is deliberate legacy behavior so old desktop sites remain tappable.

The wrong fix you will find in old answers: gating hover behind a min-width media query. It breaks on small desktop windows, on tablets with mice, and on large phones in landscape. Capability queries beat viewport guesses, always.

The Fix: Gate Hover on Capability, Not Screen Size

/* before: sticks on every phone */
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgb(0 0 0 / 0.15);
}

/* after: only on devices that truly hover */
@media (hover: hover) and (pointer: fine) {
  .card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgb(0 0 0 / 0.15);
  }
}

On a phone, the whole block is skipped: no hover styles exist to stick. On a desktop, everything works exactly as before. The pattern is mechanical: find hover rules that are pure decoration (lifts, glows, underlines) and move them inside the query. Leave functional hover alone, like tooltips that are also reachable by focus.

Why Both Conditions (hover AND pointer)

(hover: hover) asks "can the primary input hover at all", (pointer: fine) asks "is the primary pointer accurate". You want both because of the odd devices in between: some Android phones report hover capability with a coarse pointer, and some stylus setups report a fine pointer without true hover. The pair together means "a mouse-like device", which is the only input where hover styles make sense. This exact pair is what modern tooling converged on.

Press Feedback for Touch: :active + Tap Highlight

Removing sticky hover leaves touch users with dead feeling buttons. Give them press feedback instead.:active fires during the actual press on touch, which is the honest signal:

.btn {
  /* kill the gray flash Mobile Safari/Chrome paint on tap */
  -webkit-tap-highlight-color: transparent;
}

/* press feedback that works on touch AND mouse */
.btn:active {
  transform: scale(0.97);
}

Keep :active outside the media query so both input types get it. The tap-highlight line removes the semi-transparent gray box WebKit paints over tapped links and buttons, which otherwise fights your own press style. One caution: never remove the highlight without providing your own :active or :focus-visible style, or taps feel unresponsive.

Tailwind v4 users: you are already covered. Tailwind v4 wraps its hover: variant in @media (hover: hover) and (pointer: fine) automatically, so utilities like hover:-translate-y-1 never stick on touch. Design the button in our free Tailwind Button Studio and the hover output is touch-safe by default. This guide is for your raw CSS, component libraries, and design-system code outside Tailwind.

Test It: DevTools Device Emulation

You do not need a device lab for the first pass. In Chrome DevTools, toggle device emulation and pick a phone: the emulated environment reports (hover: none), so your gated hover styles disappear and the sticky behavior is gone. Then test the reverse: with emulation off, hover works normally. For the final check, use one real Android and one real iPhone, because emulation does not reproduce every vendor quirk.

The Misreporting Caveat

Honest nuance: capability reporting is not perfect. iOS Safari has a known quirk where it reports hover: none even when a mouse or trackpad is attached, and some ChromeOS convertibles flip their report when the keyboard detaches. In practice this fails safe: the worst case is a mouse user who does not get a decorative lift effect, never a broken control. Do not put information or functionality exclusively behind hover; keep it decorative and this caveat costs you nothing.

Quick Recap

  1. Taps fake a hover that never leaves because there is no cursor to move away. It is legacy behavior, not your bug.
  2. Move decorative :hover rules inside @media (hover: hover) and (pointer: fine).
  3. Use both conditions: together they mean a true mouse-like device.
  4. Give touch users :active press feedback and clear -webkit-tap-highlight-color, but never remove feedback entirely.
  5. Tailwind v4 already gates hover: for you. Raw CSS and component libraries need the manual fix.
  6. Never gate min-width for this, and never hide functionality behind hover alone.

any-hover: Designing for Mixed Inputs

hover and pointer describe the primary input. any-hover and any-pointer describe every input the device has. A Windows laptop with a touchscreen reports hover: hover because the mouse is primary, but fingers on that screen still fake a hover that sticks. In practice I gate decorative hover on (hover: hover) and (pointer: fine), exactly as the main guide says, and then I use @media (hover: none) as the touch-specific branch: larger tap targets, no hover-revealed content, no decorative lifts. any-hover: none catches devices where nothing hovers at all. Most of the time the primary-input pair is enough. Reach for the any-* variants when a hybrid device misbehaves in testing and you need to tell the two input modes apart.

/* touch branch: bigger targets, no hover-only content */
@media (hover: none) {
  .btn {
    padding: 0.9rem 1.4rem;
  }
  .card .hint {
    display: block; /* never hide info behind hover on touch */
  }
}

Do Not Forget Keyboard Users

Gating hover changes nothing for keyboards, and that is worth preserving deliberately. :focus-visible stays outside the media query, always. The pattern I use: decorative hover inside the gate, focus styles outside it, and where both should look the same I write the declaration twice rather than combining the selectors. A combined :is(:hover, :focus-visible) rule cannot straddle the media query boundary, and splitting the two keeps the touch behavior correct. Then test with the keyboard after the touch test: tab through the page and confirm every hover-styled control still shows its state on focus. If a control only communicated through hover, that was already a bug. The gate just makes it visible.

Auditing a Stylesheet Full of Hover

On an existing codebase the fix is mechanical. Grep for :hover across your stylesheets, then sort each hit into decoration or function. Decoration (lifts, color shifts, underlines) moves inside the media query. Function (revealed menus, tooltips, anything carrying information) gets redesigned for tap; the media query cannot fix those. I do it file by file, component by component, and test each on a real phone before moving on. The job is smaller than it looks. Most :hover rules are decoration, and decoration is a cut-and-paste move.

Frequently Asked Questions

Which browsers support (hover: hover)?

Effectively all of them, for about a decade: Chrome 38+, Edge 12+, Firefox 64+, desktop Safari 9+, Chrome Android 50+, Firefox Android 64+, iOS Safari 9+, Samsung Internet 5. No fallback or progressive enhancement dance needed.

Should I also gate :focus styles?

No. :focus-visible is the keyboard and assistive-tech path and it already behaves sanely on touch (it does not stick the way hover does). Leave focus styles exactly where they are.

What about :active sticking?

:active applies while the press is held and releases on lift, so it cannot stick the way hover does. If you see a stuck active state, something else is wrong (usually a focus style you mistook for active).

Does this affect dropdown menus that open on hover?

Those need a redesign, not a media query. A menu that only opens on hover is unreachable on touch regardless of sticking. Make it open on tap/click (or focus), and use the hover gate only for the decorative parts.

Share this guide