The any-pointer media feature detects whether any pointing device on the system is precise (mouse), imprecise (touch), or absent. Use it to size controls and layouts for real input capabilities.
01
@media
Media query.
02
fine
Mouse/stylus.
03
coarse
Touchscreen.
04
none
No pointer.
05
vs pointer
Primary input.
06
Touch targets
Bigger taps.
Fundamentals
Introduction
The @media any-pointer feature in CSS checks what kinds of pointing devices are available to the user — a mouse, stylus, touchscreen, or none at all. Unlike the pointer media feature, which looks at the primary input only, any-pointer evaluates all available pointing devices.
This is valuable for responsive design. A tablet in portrait mode might primarily use touch (coarse), but if the user connects a mouse, any-pointer: fine can match so you can offer tighter, desktop-style controls.
Definition and Usage
Wrap CSS rules in @media (any-pointer: fine), @media (any-pointer: coarse), or @media (any-pointer: none). The browser reports the best available pointer type across all inputs and applies matching styles.
💡
Beginner Tip
Pair any-pointer: coarse with larger buttons and links (at least 44×44 px). Pair any-pointer: fine with compact toolbars and smaller hit areas. Always start with touch-friendly defaults.
Foundation
📝 Syntax
Use any-pointer inside an @media rule to target different pointer precisions:
syntax.css
@media(any-pointer:fine){/* High-precision pointer (mouse, stylus) */}@media(any-pointer:coarse){/* Low-precision pointer (touchscreen) */}@media(any-pointer:none){/* No pointing device available */}
Accepted Values
fine — A high-precision pointing device (mouse or stylus) that allows pixel-accurate interaction.
coarse — A low-precision pointing device (finger on a touchscreen) where taps are less exact.
none — No pointing device is available (keyboard-only or voice navigation).
Use any-pointer when interaction precision affects usability:
Touch target sizing — Enlarge buttons and links on coarse devices.
Dense toolbars — Allow smaller icon buttons on fine devices only.
Hybrid laptops — Enable mouse-precision UI when any fine pointer exists.
Form controls — Increase checkbox/radio hit areas on touch screens.
Game or canvas UIs — Adjust control density based on pointer accuracy.
Preview
👀 Live Preview
Unlike viewport queries, any-pointer reflects your hardware — it does not change when you resize the window. The button below shows which query matches on your device:
Matched: (any-pointer: fine) — mouse or stylus detectedMatched: (any-pointer: coarse) — touch onlyMatched: fine + coarse — hybrid deviceMatched: (any-pointer: none) — no pointing device
Hands-On
Examples Gallery
Practice any-pointer with buttons, touch targets, toolbars, and media feature comparisons.
📜 Core Patterns
Style elements based on pointing device precision.
Example 1 — Button styling by pointer type
Change the button background depending on pointer precision — blue for fine (mouse), green for coarse (touch):
Fine pointers allow smaller 32 px icon buttons. Coarse pointers get 44 px squares for comfortable tapping.
Example 4 — any-pointer vs pointer on hybrid devices
A touchscreen laptop may report pointer: coarse but any-pointer: fine when a mouse is connected:
any-pointer-vs-pointer.css
/* Primary input only */@media(pointer:coarse){.panel{padding:1.5rem;}}/* Any available input — detects connected mouse */@media(any-pointer:fine){.panel--compact{padding:0.75rem;font-size:0.875rem;}}@media(any-pointer:coarse)and(pointer:coarse){.panel{padding:1.5rem;}}
Use any-pointer when you want to enable precision UI whenever any fine pointer exists, not just when it is primary.
Tips
💬 Usage Tips
Mobile-first sizing — Default to coarse-friendly sizes; tighten layout under any-pointer: fine.
Pair with any-hover — Combine pointer precision and hover capability for complete input adaptation.
44 px minimum — Aim for at least 44×44 CSS pixels for tap targets on coarse devices.
Do not use width alone — Large desktop screens can still be touch-only (kiosk, tablet).
Test hybrid devices — Verify behavior with and without a connected mouse on touchscreen laptops.
Watch Out
⚠️ Common Pitfalls
Tiny touch targets — Do not use fine-only sizing as the default; touch users will miss small buttons.
Confusing with any-hover — any-pointer is about precision; any-hover is about hover capability. They complement each other.
Assuming coarse = mobile — Some desktops have touch screens; some tablets have mice.
Ignoring none — Keyboard-only users may match any-pointer: none; ensure focus navigation works.
Over-nesting queries — Keep media query logic readable; extract shared base styles first.
A11y
♿ Accessibility
Minimum target size — WCAG recommends at least 44×44 px for pointer inputs on coarse devices.
Keyboard navigation — Users with any-pointer: none rely on Tab and Enter; provide visible :focus styles.
Do not shrink on touch — Never make controls smaller on coarse devices than on fine devices.
Spacing between targets — Add gap between adjacent tap targets to prevent mis-taps.
Progressive enhancement — Core actions must work without fine pointer precision.
🧠 How any-pointer Works
1
Browser scans inputs
The user agent lists all pointing devices: mouse, trackpad, touchscreen, stylus, etc.
Detect
2
Precision is classified
Each device is rated fine, coarse, or none. any-pointer uses the best available type.
Classify
3
@media rules apply
Matching @media (any-pointer: …) blocks update layout and control sizes.
Apply
=
👆
Comfortable interaction
Controls fit the user’s actual pointing precision.
Compatibility
🖥 Browser Compatibility
The any-pointer media feature is supported in all modern browsers.
✓ Baseline · Modern browsers
Pointer detection in production
any-pointer works in Chrome, Firefox, Safari, Edge, and Opera.
96%Global support
any-pointer media feature96% supported
Bottom line:any-pointer is safe for touch-target and precision UI patterns. Always test on real touch and mouse devices.
Wrap Up
🎉 Conclusion
The any-pointer media feature helps you build interfaces that respect how users actually point and tap. Whether someone uses a precise mouse, a finger on glass, or keyboard navigation alone, you can size controls and adjust density accordingly.
Combine any-pointer with any-hover for a complete picture of device input capabilities. Start with touch-friendly defaults, then enhance for fine pointers — your users get a more comfortable experience on every device.
Use these points when adapting UI for pointer precision.
5
Core concepts
@01
Media query
Device check.
Syntax
F02
fine
Mouse/stylus.
Value
C03
coarse
Touch finger.
Value
Any04
vs pointer
All inputs.
Compare
4405
Touch size
44 px targets.
A11y
❓ Frequently Asked Questions
The any-pointer media feature reports whether any available pointing device on the system is fine (precise, like a mouse), coarse (imprecise, like a finger on a touchscreen), or none. Use it to adapt layouts and control sizes for different input methods.
fine means a high-precision pointer such as a mouse or stylus that can hit small targets accurately. coarse means a low-precision pointer such as a finger on a touchscreen where taps are less exact — larger touch targets are recommended.
The pointer media feature describes the primary pointing device only. any-pointer checks all available pointing devices — so a touchscreen laptop with a connected mouse may match fine because the mouse is available, even if touch is coarse.
Use any-pointer when control size or interaction density depends on input precision: enlarge buttons and links on coarse devices, allow tighter layouts on fine devices, and avoid tiny click targets on touch screens.
Yes. any-pointer is supported in all modern browsers including Chrome, Firefox, Safari, Edge, and Opera. It is safe for production responsive design alongside touch-friendly defaults.