CSS pointer Media Feature

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

What You’ll Learn

The pointer media feature detects the primary pointing device — mouse, touchscreen, or none. Adapt button sizes, spacing, and hover behavior for how users mainly interact with your page.

01

@media

Media query.

02

fine

Mouse/trackpad.

03

coarse

Touchscreen.

04

none

Keyboard only.

05

vs any

Primary only.

06

+ hover

Pair features.

Introduction

Not every visitor uses a mouse. Phones rely on fingers, some users navigate with keyboards only, and hybrid laptops offer both touch and trackpad. The @media (pointer) feature tells CSS which primary pointing device is in use.

This is different from any-pointer, which checks all available pointing devices. The pointer feature focuses on the main input method only.

Definition and Usage

Wrap rules in @media (pointer: fine), @media (pointer: coarse), or @media (pointer: none). Enlarge tap targets on coarse, enable hover-rich UI on fine, and keep keyboard navigation clear when none matches.

💡
Beginner Tip

Start with touch-friendly defaults (large buttons, no hover-only actions). Then add fine-pointer enhancements like compact toolbars and :hover styles under @media (pointer: fine).

📝 Syntax

Use fine, coarse, or none inside an @media rule:

syntax.css
@media (pointer: fine) {
  /* Mouse or trackpad is primary */
}

@media (pointer: coarse) {
  /* Touchscreen is primary */
}

@media (pointer: none) {
  /* No pointing device (keyboard only) */
}

Accepted Values

  • fine — High-precision pointer such as a mouse, trackpad, or stylus (small targets work well).
  • coarse — Low-precision pointer such as a finger on a touchscreen (use larger tap targets).
  • none — No pointing device; user relies on keyboard or other non-pointer input.

pointer vs any-pointer

(pointer: coarse) Primary input only — a touchscreen laptop may stay coarse even with a mouse plugged in.
(any-pointer: fine) Any input available — matches when a mouse exists among connected devices.

pointer vs :hover Selector

@media (pointer: fine) Media query — applies styles when the primary device is precise (often paired with hover rules).
a:hover { } CSS selector — styles an element while the cursor is over it (does not detect device type).

Basic Example

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

@media (pointer: coarse) {
  button {
    padding: 1rem 1.75rem;
    font-size: 1.125rem;
  }
}

@media (pointer: fine) {
  button:hover {
    background: #2563eb;
    color: #fff;
  }
}

Default Value

There is no CSS default for pointer. The browser evaluates the primary input device at runtime.

Syntax Rules

  • Use keyword values only: fine, coarse, none.
  • Pair with hover for hover-capable fine pointers: @media (pointer: fine) and (hover: hover).
  • Use any-pointer when hybrid devices with multiple inputs matter.
  • Default to touch-friendly sizes; tighten under pointer: fine.
  • Never hide essential actions behind hover-only UI without a keyboard alternative.

Related Topics

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

⚡ Quick Reference

QuestionAnswer
Feature namepointer
What it measuresPrimary pointing device precision
Mouse / trackpadpointer: fine
Touchscreenpointer: coarse
Keyboard onlypointer: none
All devices checkany-pointer
Browser supportAll modern browsers

When to Use pointer

Reach for pointer when the primary input method drives the design:

  • Touch-primary phones — Enlarge buttons and links when coarse matches.
  • Desktop mouse UI — Compact controls and hover states when fine matches.
  • Keyboard-only users — Ensure focus styles and skip links when none matches.
  • Form controls — Increase checkbox and radio hit areas on touch-primary devices.
  • Navigation density — Tighter menus on fine pointers, spaced menus on coarse.

👀 Live Preview

This button adapts to your primary pointer — larger green on touch (coarse), blue with hover on mouse (fine):

Matched: (pointer: fine) — mouse or trackpad is primary Matched: (pointer: coarse) — touchscreen is primary Matched: (pointer: none) — no pointing device

Examples Gallery

Practice pointer with touch-sized buttons, hover effects, touch targets, and any-pointer comparisons.

📜 Core Patterns

Style elements based on primary pointing device precision.

Example 1 — Larger buttons on touch screens

Increase padding and font size when the primary pointer is coarse (from the reference tutorial):

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

@media (pointer: coarse) {
  button {
    padding: 1.25rem 2.5rem;
    font-size: 1.125rem;
  }
}
Try It Yourself

How It Works

Fingers need bigger tap areas than mouse cursors. This is the classic beginner pattern from the reference tutorial.

Example 2 — Hover styles on fine pointers

Add a hover effect only when the primary device is a precise pointer:

pointer-fine-hover.css
button {
  padding: 0.65rem 1.25rem;
  background: #e2e8f0;
  border: none;
  border-radius: 0.4rem;
  cursor: pointer;
}

@media (pointer: fine) {
  button:hover {
    background: #2563eb;
    color: #fff;
  }
}
Try It Yourself

How It Works

Touch users do not benefit from hover states. Scoping hover under pointer: fine avoids misleading touch-only visitors.

Example 3 — Minimum touch target size

Ensure interactive elements meet at least 44×44px on coarse primary pointers:

pointer-targets.css
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  min-height: 2.25rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.35rem;
  background: #fff;
  cursor: pointer;
}

@media (pointer: coarse) {
  .icon-btn {
    min-width: 2.75rem;
    min-height: 2.75rem;
  }
}
Try It Yourself

How It Works

Apple and WCAG recommend at least 44×44px touch targets. pointer: coarse is the right hook for touch-primary sizing.

Example 4 — pointer vs any-pointer on hybrid devices

A touchscreen laptop may report pointer: coarse but any-pointer: fine when a mouse is connected:

pointer-vs-any-pointer.css
.panel {
  padding: 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.4rem;
  margin-bottom: 0.75rem;
}

@media (pointer: coarse) {
  .panel--primary {
    background: #fef3c7;
    border-color: #fcd34d;
  }
}

@media (any-pointer: fine) {
  .panel--any {
    background: #dbeafe;
    border-color: #93c5fd;
  }
}
Try It Yourself

How It Works

Choose pointer for primary-input layouts and any-pointer when any connected mouse should unlock precision UI.

🛠 Usage Tips

  • Mobile-first sizing — Default to coarse-friendly sizes; tighten under pointer: fine.
  • Pair with hover — Use (pointer: fine) and (hover: hover) for reliable hover UI.
  • Hybrid devices — Consider any-pointer when a mouse may be connected to a touchscreen.
  • Focus styles — Always provide visible :focus for pointer: none users.
  • Test real devices — Emulators help, but phones and tablets give the true coarse result.

⚠️ Common Pitfalls

  • Confusing with any-pointerpointer is primary only; any-pointer checks all devices.
  • Hover-only actions — Never hide essential features behind hover without keyboard alternatives.
  • Tiny touch targets — Do not use fine-pointer sizing as your only button style.
  • Assuming coarse = phone — Touchscreen laptops also report coarse as primary.
  • Ignoring pointer: none — Keyboard users need full tab navigation support.

♿ Accessibility

  • 44×44px targets — Meet minimum touch size on pointer: coarse devices.
  • Keyboard navigation — Users with pointer: none rely on Tab and Enter.
  • Visible focus — Provide clear :focus-visible styles for all interactive elements.
  • No hover-only content — Tooltips and menus must work without hovering.
  • Spacing — Add margin between adjacent tap targets on coarse pointers.

🧠 How pointer Works

1

Browser detects primary input

Identifies whether touch, mouse, or no pointer is the main pointing device.

Detect
2

Media query matches a value

fine, coarse, or none.

Match
3

@media rules apply

Matching blocks update sizes, spacing, and hover behavior.

Apply
=

Input-aware UI

Layout respects how users primarily point and tap.

🖥 Browser Compatibility

The pointer media feature is supported in all modern browsers on desktop, tablet, and mobile.

Baseline · Universal support

Primary pointer queries

Works in Chrome, Firefox, Safari, Edge, and Opera.

99% Global support
pointer media feature 99% supported

Bottom line: pointer is production-ready. Combine with any-pointer and hover for complete input-aware design.

🎉 Conclusion

The pointer media feature helps you tailor UI to the primary pointing device. Use coarse for touch-friendly sizing, fine for hover-rich desktop UI, and none for keyboard-first accessibility.

Pair it with any-pointer on hybrid devices and always keep touch-friendly defaults as your foundation.

💡 Best Practices

✅ Do

  • Mobile-first tap targets
  • Pair with hover feature
  • Test on real devices
  • Visible focus styles
  • Use any-pointer on hybrids

❌ Don’t

  • Confuse with any-pointer
  • Hover-only essential actions
  • Tiny buttons on touch
  • Ignore pointer: none
  • Assume coarse = mobile only

Key Takeaways

Knowledge Unlocked

Five things to remember about pointer

Use these points when building input-aware interfaces.

5
Core concepts
F 02

fine

Mouse primary.

Value
P 03

Primary only

Not any-pointer.

Concept
H 04

+ hover

Pair features.

Pattern
44 05

Touch size

Min tap target.

A11y

❓ Frequently Asked Questions

What does the CSS pointer media feature do?

The pointer media feature reports the precision of the user's primary pointing device — fine (mouse or trackpad), coarse (touchscreen), or none (keyboard-only). Use @media (pointer: fine), (pointer: coarse), or (pointer: none) to adapt UI for the main input method.

What is the difference between fine and coarse?

fine means a high-precision pointer like a mouse that can hit small targets accurately. coarse means a low-precision pointer like a finger on a touchscreen — larger tap targets (at least 44×44px) are recommended.

What is the difference between pointer and any-pointer?

pointer checks only the primary pointing device. any-pointer checks all available pointing devices. A touchscreen laptop may report pointer: coarse even when a mouse is connected, while any-pointer: fine may still match because the mouse exists.

When should I use pointer in responsive design?

Use pointer when styles should follow the primary input method: enlarge buttons on touch-primary devices, enable hover-dependent layouts on fine-primary devices, and simplify UI when pointer: none.

Is pointer widely supported in browsers?

Yes. The pointer media feature is supported in all modern browsers including Chrome, Firefox, Safari, Edge, and Opera. It is safe for production alongside touch-friendly defaults.

Practice in the Live Editor

Open the HTML editor and experiment with @media (pointer: coarse) and fine-pointer hover 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