v156 · css · scroll snap

Use scroll-snap-type: pair to snap to a single element

With scroll-snap-type: both mandatory, the browser evaluates horizontal and vertical snap positions independently — meaning a 2D scroll container with Card A at (40, 260) and Card B at (260, 40) can snap to the empty cross-axis coordinate (40, 40) where no element exists at all. Chrome 156 adds the pair axis keyword (scroll-snap-type: pair mandatory and scroll-snap-type: pair proximity), forcing both axes to snap to the same single element.

concepts

  1. Both vs. pair 2D canvas

    Interactive 2D scroll container with staggered diagonal cards at (40, 260) and (260, 40) comparing scroll-snap-type: both mandatory (which snaps to the empty (40, 40) phantom intersection) against scroll-snap-type: pair mandatory, complete with a live CSS.supports probe, snap target buttons, and a coupled-pair simulator fallback when native pair is unavailable.

  2. Spatial mind-map navigator

    A practical 2D spatial node canvas and mind-map explorer where panning or clicking node jump controls demonstrates single-element 2D snapping with live (scrollLeft, scrollTop) Euclidean distance-to-node telemetry and scrollsnapchange state synchronization.

  3. Diagonal gallery & phantom-intersection inspector

    Interactive 2D snap-grid geometry visualizer plotting real element coordinates alongside the N² − N phantom cross-axis intersections generated by scroll-snap-type: both, with adjustable node counts, layout presets, and distance vector diagnostics.

why it shipped

When CSS Scroll Snap Module Level 1 introduced scroll-snap-type: both, its spec algorithm evaluated inline (X) and block (Y) snap offsets on orthogonal axes independently. That works for strict rectilinear spreadsheets where every row/column intersection contains a cell, but fails badly on staggered 2D canvases, mind maps, photo boards, and node graphs: any two elements at (X_A, Y_A) and (X_B, Y_B) manufacture two synthetic snap coordinates (X_A, Y_B) and (X_B, Y_A) over empty whitespace.

The new pair keyword selects a single candidate element whose combined 2D snap offset (X_i, Y_i) minimizes distance from the natural scroll end position, guaranteeing that when scrolling settles, an actual element is framed in the scrollport.

research record — use cases & exact surface

references