Skip to content

[css-scroll-snap] Clarify snapping behavior with multiple single-axis scrollers #14018

Open

Description

@vmpstr

Context

We resolved to create single-axis scrollers by allowing a scrollable value in one axis and clip in the other: #12289
This allowed us to create interesting effects and we resolved that sticky, for example, tracks per axis scrollers: #865 (comment)
@tabatkins put together a draft PR to update a bunch of specs to recognize single-axis scrollers: #13903

Problem & Proposal

One of the questions is whether scroll snap also tracks per-axis scrollers. I think that would be reasonable. One hiccup is that scroll-snap-type includes an axis in which this scroller snaps.

So, it's pretty clear what happens in a y-only scroller with a y-only scroll-snap-type: it should only snap in y and snapping in x can happen in some ancestor scroller:

/* does _not_ capture x snapping, it's not a scroller in that axis and scroll-snap-type doesn't include that axis */
.scroller {
  overflow-y: scroll;
  overflow-x: clip;
  scroll-snap-type: y mandatory;
}

Similarly, if the scroller is a scroller in both axis, then that's just the current state: nothing propagates to ancestor scrollers

However, what happens if we have a y-only scroller with a snap that includes the x axis?

.scroller {
  overflow-y: scroll;
  overflow-x: clip;
  scroll-snap-type: both mandatory;
}

I think it's reasonable to say that because this container is a not a scroller in the x direction, then it cannot prevent some ancestor from snapping in the x direction, so the scroll-snap-type here is essentially ignored when it comes to x direction of some ancestor scroller. That seems to be similar to how we deal with sticky.

For completeness, @flackr also pointed out that if the developer doesn't want some ancestor scroller to snap in the x axis, they can always say scroll-snap-align: center none (in horizontal-tb)

The proposal is to clarify that scroll snap also respects single axis scrollers and "propagates" across such scrollers in the axis for which the scroller clips

Activity

  1. flackr commented on Jun 5, 2026

    @flackr
    Contributor

    This makes sense to me, since it's establishing the same behavior we have for non-scroll containers on these non-scrolling axes. Just to play devil's advocate, we could only propagate the other axis if the inner snap container didn't claim any snap behavior for it, but this would be inconsistent with what we do for overflow: clip on both axes, so i have a preference for ignoring the clip axis snap type.

  2. css-meeting-bot commented on Jul 22, 2026

    @css-meeting-bot
    Member

    The CSS Working Group just discussed [css-scroll-snap] Clarify snapping behavior with multiple single-axis scrollers, and agreed to the following:

    • RESOLVED: Snap positions affect the nearest ancestor scroll container in each axis they align to
    The full IRC log of that discussion <kbabbitt> vmpstr: we have resolved to be able to create single axis scrollers by not coercing overflow clip into hidden
    <kbabbitt> ... when the other axis is something like scroll
    <kbabbitt> ... this means that the element becomes a scroller in one axis but not the other
    <kbabbitt> ... TabAtkins put together a draft PR to update a bunch of specs for this
    <TabAtkins> (no longer a draft PR, it's merged now)
    <kbabbitt> ... a lot of cases you have to find nearest scroll container and which axis matters
    <kbabbitt> ... this issue is about scroll-snap
    <kbabbitt> ... I think we want to say it's reasonable to want to snap 2 different scrollers for 2 different axes
    <kbabbitt> ... one smallproblem here is that scroller, when it specifies snap type, also specifies an axis
    <kbabbitt> ... question is what do we do in these cases
    <kbabbitt> ... think it's obvious for vertical scroller with vertical axis
    <TabAtkins> definitely +1 to the proposal in the issue, it's consistent with the non-scrolling behavior and how we treat single-axis scrollers elsewhere
    <kbabbitt> ... question is what do we do if we have a vertical scroller with snap in horizontal axis
    <kbabbitt> ... proposal I have is that we ignore the fact that scroll-snap-type has horizontal axis since scroller is not horizontal
    <kbabbitt> ... would find scroller higher up
    <kbabbitt> ... examp[les in the issue
    <kbabbitt> flackr: this is the same as what we do for scroll-snap-type on non-scroller
    <kbabbitt> vmpstr: right, first we find a scroller then check its scroll-snap-type
    <kbabbitt> astearns: questions or concerns?
    <flackr> +1 to the proposal
    <smfr> q+
    <TabAtkins> non-scrolling axises don't capture snaps
    <kbabbitt> vmpstr: scroll-snap-type which doesn't affect a scroller doesn't contribute scroll points
    <kbabbitt> smfr: if you have nested scrollers and inner scroller is horizontal, when you're selecting snap candidates in parent scroller, you are looking at ones in inner scroller?
    <kbabbitt> vmpstr: the ones for other axis, yes
    <kbabbitt> smfr: when you specify a snap target, do you give it an axis?
    <kbabbitt> flackr: yes, you specify scroll-snap-align in each axis
    <kbabbitt> smfr: guess that makes sense
    <kbabbitt> astearns: this makes sense to me but summary in minutes doesn't yet
    <kbabbitt> ... when there's a mismatch between scroll-snap-type and scroll axes, we ignore the mismatched scroller?
    <kbabbitt> vmpstr: essentially you do bitwise and between scroll-snap-type axis and which axis the element is a scroller
    <flackr> Proposed resolution: Snap positions affect the nearest ancestor scroll container in each axis they align to
    <kbabbitt> ... if it has both but scroller is only vertical only consider snapping in vertical axis, horizontal snap can be in ancestor scroller
    <flackr> existing spec text is "Snap positions only affect the nearest ancestor scroll container on the element’s containing block chain."
    <TabAtkins> yeah +1 to resolution
    <kbabbitt> flackr: wrote a resolution based on existing spec text
    <kbabbitt> ... I am proposing that we just say "in each axis which they align to"
    <ChrisL> +1
    <kbabbitt> astearns: right because really we are affecting scrolling of scroll container based on what scroll positions
    <kbabbitt> astearns: any objections to flackr's proposed resolution?
    <kbabbitt> RESOLVED: Snap positions affect the nearest ancestor scroll container in each axis they align to
  3. zcorpan commented on Oct 12, 2026

    @zcorpan
    Contributor

    #14354 was merged, but maybe this still needs tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions