CSS any-pointer Media Feature

Beginner
⏱️ 7 min read
📚 Updated: Jul 2026
🎯 4 Examples
Media Queries

What You’ll Learn

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.

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.

📝 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).

Basic Example

any-pointer-basic.css
button {
  padding: 0.65rem 1.25rem;
  cursor: pointer;
}

@media (any-pointer: fine) {
  button {
    background: #93c5fd;
    border: 2px solid #2563eb;
  }
}

@media (any-pointer: coarse) {
  button {
    background: #86efac;
    border: 2px solid #16a34a;
  }
}

any-pointer vs pointer Media Feature

(pointer: coarse) Describes the primary pointing device only. A laptop with touch as primary may always report coarse even when a mouse is plugged in.
(any-pointer: fine) Checks all inputs. If any device is fine (e.g. a connected mouse), this matches — better for hybrid devices.

Default Value

There is no CSS default for any-pointer. The browser evaluates the user’s actual hardware at runtime.

Syntax Rules

  • Valid values are fine, coarse, and none only.
  • Combine with other features: @media (any-pointer: coarse) and (max-width: 48rem).
  • Works alongside any-hover for complete input adaptation.
  • Prefer any-pointer over pointer when hybrid touch-and-mouse devices matter.
  • Start with coarse-friendly sizes; enhance for fine pointers.

Related Topics

@media (any-pointer: fine) @media (any-pointer: coarse) @media (any-pointer: none)

⚡ Quick Reference

QuestionAnswer
Feature nameany-pointer
Valuesfine, coarse, none
What it detectsPointer precision of any available input
fine typical matchDesktop/laptop with mouse or stylus
coarse typical matchPhones and tablets (finger touch)
Browser supportAll modern browsers

When to Use any-pointer

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.

👀 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 detected Matched: (any-pointer: coarse) — touch only Matched: fine + coarse — hybrid device Matched: (any-pointer: none) — no pointing device

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):

any-pointer-button.css
button {
  padding: 0.65rem 1.25rem;
  font-size: 1rem;
  cursor: pointer;
}

@media (any-pointer: fine) {
  button {
    background-color: #93c5fd;
  }
}

@media (any-pointer: coarse) and (not (any-pointer: fine)) {
  button {
    background-color: #86efac;
  }
}
Try It Yourself

How It Works

The browser picks the best matching pointer type across all inputs and applies the corresponding button style.

Example 2 — Larger touch targets on coarse pointers

Increase padding and minimum size for links and buttons when the user taps with a finger:

any-pointer-targets.css
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.5rem 1rem;
}

@media (any-pointer: coarse) {
  .btn {
    min-height: 2.75rem;
    min-width: 2.75rem;
    padding: 0.75rem 1.25rem;
    font-size: 1.0625rem;
  }
}

@media (any-pointer: fine) {
  .btn {
    min-height: 2rem;
    padding: 0.4rem 0.85rem;
    font-size: 0.875rem;
  }
}
Try It Yourself

How It Works

Coarse pointers get bigger minimum dimensions (44 px recommended). Fine pointers can use compact controls.

Example 3 — Compact icon toolbar for fine pointers

Show a dense icon toolbar only when a precise pointer is available:

any-pointer-toolbar.css
.toolbar {
  display: flex;
  gap: 0.5rem;
}

.toolbar button {
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 0.35rem;
}

@media (any-pointer: fine) {
  .toolbar button {
    width: 2rem;
    height: 2rem;
    padding: 0;
    font-size: 0.875rem;
  }
}

@media (any-pointer: coarse) {
  .toolbar button {
    width: 2.75rem;
    height: 2.75rem;
    font-size: 1.125rem;
  }
}
Try It Yourself

How It Works

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; }
}
Try It Yourself

How It Works

Use any-pointer when you want to enable precision UI whenever any fine pointer exists, not just when it is primary.

💬 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.

⚠️ Common Pitfalls

  • Tiny touch targets — Do not use fine-only sizing as the default; touch users will miss small buttons.
  • Confusing with any-hoverany-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.

♿ 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.

🖥 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 feature 96% supported

Bottom line: any-pointer is safe for touch-target and precision UI patterns. Always test on real touch and mouse devices.

🎉 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.

💡 Best Practices

✅ Do

  • Size touch targets for coarse pointers
  • Use any-pointer on hybrid devices
  • Combine with any-hover when needed
  • Test with mouse and touch
  • Keep keyboard focus visible

❌ Don’t

  • Default to tiny fine-only buttons
  • Assume screen width equals pointer type
  • Ignore any-pointer: none users
  • Confuse pointer and any-pointer
  • Skip real-device testing

Key Takeaways

Knowledge Unlocked

Five things to remember about any-pointer

Use these points when adapting UI for pointer precision.

5
Core concepts
F 02

fine

Mouse/stylus.

Value
C 03

coarse

Touch finger.

Value
Any 04

vs pointer

All inputs.

Compare
44 05

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.

Practice in the Live Editor

Open the HTML editor and experiment with @media (any-pointer: fine) and touch-target sizing patterns.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful