touch-action · CSS

On this page 7

touch-action is the CSS property that declares which touch gestures the browser may handle natively on an element, such as panning, scrolling and pinch zooming, and which gestures it must leave to page scripts. On the mobile web it is the standard way to stop the browser from scrolling or zooming while a custom widget, such as a map, a drawing canvas or a carousel, processes the same finger movement itself.

The property is defined in the W3C Pointer Events specification and is supported by all current mobile browsers. Because it is declarative, the browser knows the allowed gestures before the first touchmove event fires, which lets it keep scrolling on the fast compositor thread instead of waiting for JavaScript.

How touch-action decides gesture ownership

When a finger touches the screen, the browser performs a hit test and then computes the effective touch-action for that contact point. It does this by intersecting the touch-action values of the touched element and every ancestor up to the nearest scroll container, so a restriction set on a parent cannot be loosened by a child.

The result is fixed at the start of the gesture. Changing the property in a script halfway through a swipe has no effect on that swipe; it applies only to the next touch. Anything the browser is not allowed to handle becomes a regular stream of pointer events or touch events for page code, and the browser sends a pointercancel event when it takes over a gesture it is permitted to handle.

This model explains why touch-action matters for performance. Without it, a page that wants to block scrolling must call preventDefault() inside a touchmove listener, which forces the browser to wait for the main thread before every scroll frame. With touch-action, the decision is available up front, and scroll listeners can be registered as passive listeners without losing control over the gesture.

Values of the touch-action property

The property accepts keyword values that either name a single behavior or combine pan directions with zoom. The following table lists the values defined in the specification and what each permits.

ValueBrowser may handleTypical use
autoAll panning and zoomingDefault for ordinary content
noneNo panning or zoomingCanvas, maps, games
pan-xHorizontal panning onlyVertical custom sliders
pan-yVertical panning onlyHorizontal carousels
pan-left, pan-right, pan-up, pan-downPanning that starts in one directionPull-to-refresh, edge swipes
pinch-zoomMulti-finger zoom and its panningCombined with pan values
manipulationPanning and pinch zoom, no double-tap zoomButtons and tap targets
Standard touch-action values and their effect

Values can be combined, for example pan-x pinch-zoom or pan-y pinch-zoom, but auto, none and manipulation must stand alone. The value manipulation became popular because removing double-tap zoom also removes the old 300-millisecond tap delay that browsers once added while waiting for a possible second tap. Modern browsers already skip that delay when the viewport meta tag sets width=device-width, so manipulation is now mainly a safeguard.

The single-direction values such as pan-down are less widely supported than the axis values. Teams that rely on them should test on real devices and design a fallback that still works when only pan-x and pan-y are honored.

Several mechanisms influence what happens when a user drags a finger across a page. They overlap in purpose but work at different layers of the browser, as the next table shows.

TechniqueLayerWhat it controlsMain drawback
touch-actionCSS, declarativeNative pan and zoom per elementFixed at gesture start
preventDefault() in touchmoveJavaScriptCancels default per eventBlocks fast scrolling
overscroll-behaviorCSS, declarativeScroll chaining and bounceDoes not stop panning
user-scalable=no in viewportHTML meta tagPage-wide zoomHarms accessibility
Pointer captureJavaScript APIWhich element receives eventsDoes not stop native gestures
touch-action compared with neighboring techniques

The key distinction is that touch-action decides ownership of the gesture, while overscroll-behavior only decides what happens when a scroll container reaches its edge. Pinch to zoom, touch events and the viewport meta tag are neighboring concepts in the mobile web: touch-action is the element-level control that coordinates all of them.

Applying touch-action in real interfaces

The safest approach is to restrict only the gesture a widget actually needs and leave everything else to the browser. A horizontal carousel needs the horizontal axis, so declaring pan-y keeps vertical page scrolling native while the script handles sideways swipes.

ComponentRecommended valueReason
Image carouselpan-yPage still scrolls vertically
Interactive mapnoneScript owns pan and zoom
Signature or drawing padnoneStrokes must not scroll the page
Range sliderpan-y or pan-xFree the axis the thumb does not use
Zoomable photo viewerpan-x pan-yNative panning, custom zoom
Tap-heavy buttonsmanipulationNo accidental double-tap zoom
Recommended values for common mobile components

Apply the value to the interactive element itself, not to body or html. A page-wide touch-action: none disables scrolling and zooming for the entire document, which is one of the most serious accessibility failures a mobile site can introduce.

  • Pair touch-action with pointer events so mouse, pen and touch share one code path.
  • Register scroll and touch listeners as passive when they never cancel the default.
  • Keep the restricted area visibly distinct so users know where gestures behave differently.
  • Verify behavior in Chrome DevTools device mode and on at least one physical iOS and Android device.

Limitations and common mistakes

Most problems with touch-action come from misunderstanding its inheritance rules or its timing. The property is not inherited in the CSS sense, yet its effect still combines with ancestors through the intersection rule, which surprises many developers.

SymptomCauseFix
Page cannot be scrollednone set on a large containerLimit none to the widget
Child value ignoredAncestor already restricts gesturesRelax the ancestor value
Swipe still scrollsValue changed mid-gestureSet the value before touch starts
Users cannot zoom textnone or pan values without pinch-zoomAdd pinch-zoom where possible
Works on desktop onlyTested with a mouse, not touchTest with real touch input
Frequent touch-action problems and their fixes

touch-action also does not affect mouse wheels or trackpads; it only applies to direct manipulation by touch and, in some browsers, pen input. Developers who need to control wheel scrolling still require overscroll-behavior or event handling, and they should treat touch-action as one part of a gesture strategy, not a complete solution.

Put simply

When you drag a finger on a phone, the browser usually assumes you want to scroll or zoom the page. That is great for reading, but it gets in the way when you are drawing a signature or moving a map.

touch-action is a short instruction a web page gives the browser about one specific area: here, leave this movement to me. It works like a sign on a door saying who is responsible for what. The rest of the page keeps scrolling normally, and only the marked area behaves differently.

In practice

A delivery company builds a mobile web page where couriers collect a customer signature on a canvas about 300 by 150 pixels. In early tests, every downward stroke of the pen scrolled the page, so the signatures came out as broken fragments and couriers had to ask customers to sign again.

The developers add touch-action: none to the canvas only and switch the drawing code from touch events to pointer events. The surrounding form still scrolls normally, and the page keeps pinch zooming for customers who need larger text. After the change, incomplete signatures largely disappear, and the same code also works with a stylus on tablets and a mouse on desktop computers.