CSS any-pointer Media Feature

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The any-pointer media feature tests whether any available pointing device exists, and how accurate it is.

Use @media (any-pointer: fine) when a mouse, trackpad, or stylus is present. Use @media (any-pointer: coarse) when a finger or other imprecise pointer is available. Use @media (any-pointer: none) when there is no pointing device. Unlike pointer, it is not limited to the primary input — useful on hybrid touch + mouse devices.

Baseline · Widely available.

Not deprecated. Standard-track interaction media feature (Media Queries Level 4). Widely available since December 2018. Prefer comfortable touch targets by default, then refine for precision when needed.

Caveat Both fine and coarse can match

A laptop with a touchscreen can match fine and coarse at the same time. none matches only when no pointing device exists. Cascading order matters.

CSS Syntax

syntax.css
@media (any-pointer: none | coarse | fine) { … }

Always wrap the feature in parentheses. Invalid forms like @media any-pointer(fine) do not work.

Feature Values

ValueDescriptionTry it
fineAt least one accurate pointing deviceTry it
coarseAt least one limited-accuracy pointing deviceTry it
noneNo pointing device availableTry it
vs pointerAny input vs primary input onlyTry it

How to Use any-pointer

Ship comfortable targets first, then enlarge for coarse pointers or tighten only when a fine pointer is available.

  1. Size buttons and links so they work with a finger (about 44×44 px is a solid default).
  2. Enlarge further with @media (any-pointer: coarse) when needed.
  3. Optionally tighten spacing with @media (any-pointer: fine) for mouse-dense UIs.
  4. Compare with pointer when only the primary device matters.
PieceRequired?Role
@mediaYesWraps the media feature
any-pointer keywordYesfine, coarse, or none
Default target sizeYesMust stay usable on touch
Coarse / fine overridesOptionalAdapt density to available pointers

Live Preview

This device’s any-pointer result via matchMedia. The sample button grows when (any-pointer: coarse) matches.

Detected any-pointer queries

Watch the chips update. Hybrid devices may light up both fine and coarse.

any-pointer detection
(any-pointer: fine) (any-pointer: coarse) (any-pointer: none)

Checking…

CSS Examples

Each snippet focuses on the any-pointer media feature. Keep defaults touch-friendly, then adapt for precision. Use Try It Yourself for a live editor.

Example 1 — Larger Targets for Coarse Pointers

Enlarge a button when any limited-accuracy pointer is available.

CSS
<style>
  button {
    background: #2563eb;
    color: #fff;
    border: 0;
    padding: 12px 16px;
    font: inherit;
  }

  @media (any-pointer: coarse) {
    button {
      padding: 18px 24px;
      min-height: 48px;
    }
  }
</style>

<button type="button">Save</button>
Try It Yourself

How It Works

  1. Start usable. Default padding works for mouse and many phones.
  2. Detect coarse input. @media (any-pointer: coarse) matches finger-sized pointers.
  3. Enlarge the hit area. Extra padding and min-height reduce miss-taps.
  4. Hybrid-safe. A phone with a mouse still gets the larger target if touch remains available.

Example 2 — Compact UI for Fine Pointers

Tighten button padding when an accurate pointer is available.

CSS
<style>
  button {
    background: #2563eb;
    color: #fff;
    border: 0;
    padding: 14px 18px;
    font: inherit;
  }

  @media (any-pointer: fine) {
    button {
      padding: 8px 12px;
    }
  }
</style>

<button type="button">Edit</button>
Try It Yourself

How It Works

  1. Keep a roomy default. Touch users are covered first.
  2. Detect a fine pointer. Mice and styluses match (any-pointer: fine).
  3. Tighten the chrome. Smaller padding suits dense desktop toolbars.
  4. Watch hybrids. If coarse also matches, declare coarse overrides after fine or avoid shrinking.

Example 3 — any-pointer vs pointer

Compare primary-only pointer with any-input any-pointer.

CSS
<style>
  .box {
    padding: 12px;
    border: 1px solid #64748b;
  }

  .primary::after { content: " — unknown"; }
  .any::after { content: " — unknown"; }

  @media (pointer: fine) {
    .primary::after { content: " — fine"; }
  }
  @media (pointer: coarse) {
    .primary::after { content: " — coarse"; }
  }
  @media (pointer: none) {
    .primary::after { content: " — none"; }
  }

  @media (any-pointer: fine) {
    .any::after { content: " — fine"; }
  }
  @media (any-pointer: coarse) {
    .any::after { content: " — coarse"; }
  }
  @media (any-pointer: none) {
    .any::after { content: " — none"; }
  }
</style>

<p class="box primary">pointer (primary)</p>
<p class="box any">any-pointer (any)</p>
Try It Yourself

How It Works

  1. Query primary pointer. pointer reflects the main pointing device.
  2. Query any pointer. any-pointer scans all pointing devices.
  3. Compare the results. A touch-first laptop with a mouse may differ.
  4. Pick the right feature. Use any-pointer when accessory pointers matter.

Edge Cases & Pitfalls

Hybrid devices are where any-pointer and pointer most often disagree.

vs pointer

Any input vs primary input

pointer is primary-only. any-pointer is true for each matching device class. Prefer any-pointer for accessory mice and pens.

both match

fine and coarse together

Both can match on convertibles. Put the safer (usually coarser) rules later in the cascade, or avoid shrinking targets when coarse also matches.

defaults

Tiny defaults fail on touch

Do not start with 24×24 px controls and only enlarge for coarse. Ship comfortable defaults, then refine for fine.

a11y

Keyboard users still need focus

Pointer accuracy does not replace :focus-visible. Keep focus rings clear for keyboard navigation.

Browser Support

any-pointer is a browser media feature. Node.js, Deno, and Bun do not evaluate it.

✓ Baseline · Widely available since Dec 2018

any-pointer

Chrome 41+, Edge 12+, Firefox 64+, Safari 9+, Opera 28+, Samsung Internet 4+. Internet Explorer has no support.

97% Global reach
Google Chrome 41+
Full support
Mozilla Firefox 64+
Full support
Apple Safari 9+
Full support
Microsoft Edge 12+
Full support
Opera 28+
Full support
Samsung Internet 4+
Full support
Internet Explorer —
No support
@media (any-pointer) Widely supported

Bottom line: Safe for progressive enhancement. Keep touch-friendly defaults. It is not a server runtime API.

Key Takeaways

  • Role: detect precision of any available pointing device.
  • Values: fine, coarse, and none inside @media (…).
  • vs pointer: any input, not only the primary one.
  • Practice: roomy defaults; enlarge for coarse; tighten carefully for fine.

One line: ask how accurate any pointer is, then size interactive targets to match.

Frequently Asked Questions

It tests whether any available pointing device exists and how accurate it is. Use @media (any-pointer: fine), (any-pointer: coarse), or (any-pointer: none).
Three keywords: fine (accurate pointer like a mouse), coarse (limited accuracy like a finger), and none (no pointing device).
pointer checks only the primary pointing device. any-pointer checks all pointing devices — a tablet with a mouse can match fine even if the primary pointer is coarse.
Yes. On hybrid devices both can match at once. none matches only when there is no pointing device. Order your CSS carefully when both fine and coarse rules apply.
Prefer any-pointer when accessory pointers matter (external mouse on a phone or tablet). Prefer pointer 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.

Next: pointer

Learn the pointer media feature for primary-device fine vs coarse pointing.

pointer tutorial →

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.

8 people found this page helpful