The any-hover media feature tests whether any available input can conveniently hover over elements.
Use @media (any-hover: hover) when a mouse, trackpad, or another hover-capable device is present. Use @media (any-hover: none) when nothing can hover (typical phones without a mouse). Unlike hover, it is not limited to the primary input — useful on hybrid touch + mouse devices. It is not the same as the :hover pseudo-class.
Baseline · Widely available.
Not deprecated. Standard-track interaction media feature (Media Queries Level 4). Widely available since December 2018. Prefer touch-friendly defaults, then enhance when (any-hover: hover) matches.
Caveat Capability can change
Plugging in a mouse can flip any-hover from none to hover. Keep essential UI usable without hover, then enhance.
Syntax
CSS Syntax
syntax.css
@media (any-hover:none | hover) { … }
Always wrap the feature in parentheses. Invalid forms like @media any-hover(hover) do not work.
Query primary hover.hover reflects the main pointing device.
Query any hover.any-hover scans all available inputs.
Compare the results. A touch-first laptop with a mouse may show none vs hover.
Pick the right feature. Use any-hover when accessory pointers matter.
Edge Cases & Pitfalls
Hybrid devices are where any-hover and hover most often disagree.
vs hover
Any input vs primary input
hover is primary-only. any-hover is true if any connected input can hover. Prefer any-hover for accessory mice and pens.
vs :hover
Media feature ≠ pseudo-class
@media (any-hover) asks “can something hover?” :hover styles the element while a pointer is over it. Use both together.
sticky
Ungated :hover sticks on touch
Without (any-hover: hover), first tap can leave :hover styles stuck. Gate hover chrome with the media feature.
a11y
Keyboard users still need focus
Pair interactive styles with :focus-visible. Hover capability does not replace keyboard focus indicators.
Compatibility
Browser Support
any-hover is a browser media feature. Node.js, Deno, and Bun do not evaluate it.
✓ Baseline · Widely available since Dec 2018
any-hover
Chrome 41+, Edge 16+, Firefox 64+, Safari 9+, Opera 28+, Samsung Internet 5+. Internet Explorer has no support.
97%Global reach
Google Chrome41+
Full support
Mozilla Firefox64+
Full support
Apple Safari9+
Full support
Microsoft Edge16+
Full support
Opera28+
Full support
Samsung Internet5+
Full support
Internet Explorer—
No support
@media (any-hover)Widely supported
Bottom line: Safe for progressive enhancement. Never hide essential UI behind hover-only styles. It is not a server runtime API.
Remember
Key Takeaways
Role: detect whether any available input can hover.
Values:hover and none inside @media (…).
vs hover: any input, not only the primary one.
Practice: defaults for touch; enhance for (any-hover: hover).
One line: ask if any input can hover, then decide whether :hover styles are safe to rely on.
Frequently Asked Questions
It tests whether any available input mechanism can conveniently hover over elements. Use @media (any-hover: hover) when at least one input can hover, and @media (any-hover: none) when none can.
Two keywords: hover (one or more inputs can hover) and none (no input can hover conveniently, or there is no pointing input).
hover checks only the primary input. any-hover checks all inputs — so a touchscreen laptop with a mouse often matches (any-hover: hover) even if (hover: none).
The media feature is a capability query evaluated before interaction. The :hover pseudo-class styles an element while the pointer is over it. Gate hover-only UI with the media feature; use :hover for live feedback.
Prefer any-hover when hover-capable accessories matter (external mouse on a tablet, trackpad on a convertible). Prefer hover when you care only about the primary input.
No. It is a CSS media feature evaluated by the browser layout engine, not a Node.js or server runtime feature.