
Touch vs Pointer Input: One Codebase, All Modalities
Hover is a capability of the primary pointing device, not of the mouse alone, and WCAG sets minimum target sizes of 24 by 24 (AA) and 44 by 44 (AAA) CSS pixels, with exceptions — Pointer Events and the (hover)/(pointer) media queries make one codebase feel native on every modality.
TL;DR: By spec, hover is a capability of the primary pointing device, not of the mouse alone: the Media Queries spec gives mice, touch pads and advanced stylus digitizers as typical hover-capable devices and touchscreens as typical devices that cannot hover. For target size, WCAG 2.5.5 (Level AAA) asks for pointer targets of at least 44 by 44 CSS pixels, and WCAG 2.5.8 (Level AA) sets a minimum of 24 by 24 CSS pixels. Both criteria have exceptions: Equivalent, Inline, User Agent Control and Essential, plus Spacing for undersized targets under 2.5.8. The modern recipe for input-modality-aware UI is three layers: Pointer Events (Baseline 2020) to unify mouse, touch, and pen into one API, the (hover: hover) and (pointer: fine/coarse) media queries (Baseline 2018) to detect capability not device, and proper hit-area sizing so the same component feels native on every modality. The Popover API has been Baseline Newly available since January 2025 (as of Nov 2026, web-features) and can replace hover-only tooltips with a reveal that opens on activation (tap, click or keyboard). This piece is the practical recipe.
Why touch and mouse cannot share interactions blindly
The mouse pointer is one CSS pixel wide and can hover indefinitely without committing to a click. A fingertip covers a contact area far wider than one CSS pixel, has no hover state at all, and cannot preview a target before touching it. These are not minor differences — they are the reason "hover to reveal" interactions that work beautifully on desktop disappear on phones, and the reason desktop-sized icon buttons feel infuriating on mobile.
Touch versus pointer is also not a clean device-versus-device split. A Surface tablet running Edge can combine a touch screen with a precise stylus. A touch-screen Chromebook has a trackpad and a touch screen and supports both at the same time. A phone connected to a Bluetooth mouse can show a pointer cursor; check the platform's documentation for whether an accessibility setting has to be turned on first. The right mental model is capability detection per input event, not device detection from a user-agent string.
A hover-to-reveal pattern designed for mouse can leave secondary actions hard or impossible to reach on touch devices. A 24 by 24 pixel icon button designed for mouse pointers falls short of the 44 by 44 CSS pixel size of WCAG 2.5.5 (Level AAA, which has Equivalent, Inline, User Agent Control and Essential exceptions) the moment a thumb tries to hit it. The fix is not two implementations — it is one component that handles input modality as a property of the event, not the device.
Pointer Events: one API for all modalities
The Pointer Events API has been Baseline Newly available since July 2020, meaning it is supported in all of the core browsers, and Widely available since January 2023 (as of Nov 2026, web-features). It unifies mouse, touch, and pen into a single set of events — including pointerdown, pointermove, pointerup, pointercancel, pointerenter, and pointerleave — and adds a pointerType property on every event that reports 'mouse', 'pen', or 'touch' for those device types, an empty string when the user agent cannot detect the device type, and possibly another value, which the spec says should be vendor-prefixed, for other device types.
The migration path is gradual because PointerEvent extends MouseEvent. Code that listens for click continues to work; code that listens for mousedown works on mouse, but for touch and pen it depends on compatibility mouse events, which the Pointer Events spec makes an optional feature that user agents are encouraged, not required, to support. Replacing the latter with pointerdown covers all three modalities with one handler.
button.addEventListener('pointerdown', (event) => {
if (event.pointerType === 'touch') {
// touch-specific: maybe a longer hit visual
} else if (event.pointerType === 'pen') {
// pen-specific: pressure available via event.pressure
} else {
// mouse default
}
});The W3C Pointer Events Level 3 specification and the MDN Pointer Events reference document the full event family. The practical advice is short: replace mouseenter and mouseleave with pointerenter and pointerleave, replace mousedown and mouseup with pointerdown and pointerup, and read pointerType only when you genuinely need to branch — which is rarer than you would expect.
Detecting input modality with @media
Media queries detect capability, not device, which is exactly the right model for hybrid hardware. The W3C Media Queries Level 5 interaction features define two pairs of features that reached Baseline 2018: hover (whether the primary input can hover) and pointer (the precision of the primary input).
/* The device's primary input can hover */
@media (hover: hover) {
.card:hover .reveal { opacity: 1; }
}
/* The device's primary input is precise (mouse, pen) */
@media (pointer: fine) {
.icon-button { width: 32px; height: 32px; }
}
/* The device's primary input is coarse (finger) */
@media (pointer: coarse) {
.icon-button { width: 44px; height: 44px; }
}
/* Precise, hover-capable primary input (mouse, trackpad, advanced stylus) */
@media (hover: hover) and (pointer: fine) {
.desktop-only-affordance { display: block; }
}The combination of (hover: hover) and (pointer: fine) signals a precise, hover-capable primary input; the Media Queries spec gives a mouse, a touch pad and an advanced stylus digitizer as typical examples, and a pure touchscreen fails both. The any-hover and any-pointer variants ask whether any of the device's inputs can hover or are fine; on a Surface with both touch and pen, any-pointer: fine is true but pointer: coarse may still be the primary. Use the primary versions unless you specifically need the broader check.
These detectors should scope progressive enhancements, not gate essential functionality. A button that only works on hover-capable devices is a failure mode; a hover preview that only appears on hover-capable devices is a sound enhancement.
Touch target sizing
WCAG 2.5.5 Target Size (Enhanced) at AAA level (added in WCAG 2.1) asks for the target for pointer inputs to be at least 44 by 44 CSS pixels, except when the target is available through an equivalent link or control on the same page that is at least 44 by 44 CSS pixels (Equivalent), the target is in a sentence or block of text (Inline), the size of the target is determined by the user agent and is not modified by the author (User Agent Control), or a particular presentation of the target is essential to the information being conveyed (Essential). WCAG 2.5.8 Target Size (Minimum), new at Level AA in WCAG 2.2, sets the AA floor at 24 by 24 CSS pixels, with five exceptions. Spacing: undersized targets (those less than 24 by 24 CSS pixels) are positioned so that if a 24 CSS pixel diameter circle is centered on the bounding box of each, the circles do not intersect another target or the circle for another undersized target. Equivalent: the function can be achieved through a different control on the same page that meets the criterion. Inline: the target is in a sentence or its size is otherwise constrained by the line-height of non-target text. User Agent Control: the size of the target is determined by the user agent and is not modified by the author. Essential: a particular presentation of the target is essential or is legally required for the information being conveyed. The WCAG 2.2 Target Size Minimum SC is the authoritative reference. The 44 px target is the aspirational floor; the 24 px target is the AA minimum unless one of those exceptions applies.
The trick to hitting 44 px without bloating the visual design is to expand the hit area with padding while keeping the visual size smaller. The hit region is the bounding box of the clickable element, not the size of the icon inside it.
.icon-button {
/* 24px icon visible */
width: 24px;
height: 24px;
/* But 44x44 clickable hit area */
padding: 10px;
box-sizing: content-box;
cursor: pointer;
}The spacing exception under WCAG 2.5.8 only matters for targets smaller than 24 px: two 16 px icons placed side by side need their centers at least 24 px apart. Growing only one of them to 24 px does not remove that need: the other icon is still undersized, and its circle must still clear the larger target, so the centers still have to be 24 px apart. Only when both are at least 24 by 24 does the spacing exception stop mattering. Stacking 16 by 16 icon buttons tightly in a toolbar with no spacing fails 2.5.8 unless another of its exceptions (Equivalent, Inline, User Agent Control or Essential) applies; 24 by 24 buttons meet the 2.5.8 size requirement but still miss the 44 px target of 2.5.5.
Browser developer tools include touch simulators, but the simulator is approximate. A test on a real device with a thumb complements the simulator — not a fingertip, not a stylus, a thumb. Targets that pass at the desk can fail in one-handed use on a phone in transit. The conformance check is the developer tools; the design check is the thumb.
Hover-only interactions and how to fix them
The hover-to-reveal pattern is a touch regression to watch for. A card that shows secondary actions only on hover can leave them hard or impossible to reach on touch devices, which means a phone user can see the card but may not be able to reach the actions that the desktop user takes for granted.
The fix has two layers. First, scope the hover-only reveal to hover-capable environments with @media (hover: hover). Second, provide a touch path — typically tap-to-reveal, an always-visible secondary affordance, or a primary action that bundles the common cases without needing the hover menu.
.card .actions {
/* Visible by default — touch path */
opacity: 1;
}
@media (hover: hover) {
.card .actions {
/* Hidden until hover — mouse enhancement */
opacity: 0;
transition: opacity 150ms ease;
}
.card:hover .actions,
.card:focus-within .actions {
opacity: 1;
}
}Note the :focus-within pairing — keyboard users need a path too, and keyboard focus is the third modality alongside touch and pointer. Hover without focus or click is a triple regression.
Tooltips are the canonical hover-only pattern that needs replacing. The Popover API has been Baseline Newly available since January 2025 (as of Nov 2026, web-features) and is the right primitive for tooltip-like reveals: popovertarget on the trigger and the popover attribute on the panel give you a disclosure that, in the default auto state, has built-in light dismiss and close-request handling (the manual state has neither), working identically on touch and mouse. Unless the panel is a dialog element, focus moves into it on opening only when the panel or an element inside it has the autofocus attribute, and on an element without accessibility semantics, such as a div, the HTML spec says authors should use the appropriate ARIA attributes to make the popover accessible. For static disclosure that does not need an overlay, the <details> and <summary> pattern handles the case without JavaScript.
Phase 1 deliverables and acceptance criteria
The recipe is short and scoped to a handful of changes.
- Audit hover-only interactions across the product. Wrap each in
@media (hover: hover)or pair the hover state with a click and focus path so touch and keyboard users get there too. - Measure tap target sizes on every interactive element. Flag anything under 44 by 44 CSS pixels against the WCAG 2.5.5 (Level AAA) aspirational target, and treat anything under 24 by 24 as failing WCAG 2.5.8 (Level AA) unless one of its exceptions applies: Spacing, Equivalent, Inline, User Agent Control or Essential (2.5.5 has the last four as well).
- Replace
mouseenterandmouseleavelisteners withpointerenterandpointerleave. One listener then receives mouse, touch, and pen, though for a device that does not support hover, such as most touchscreens, there is no hover phase before contact: the user agent firespointerenterbeforepointerdownandpointerleaveafterpointerup. - Replace bespoke tooltip implementations with the Popover API where the reveal is on-demand, or
<details>and<summary>where the disclosure is structural. - Test on a real phone in one-handed use, on a tablet with a stylus, and with a Bluetooth mouse attached to a phone. The hybrid cases are where modality assumptions break.
The work is rarely glamorous, but the wins compound: discoverability for touch users, conformance for the accessibility audit, and one codebase instead of forked branches per modality.