CSS Scroll Snapping Change Proposal

Unofficial Proposal Draft,

This version:
https://drafts.csswg.org/css-scroll-snap/
Issue Tracking:
GitHub
Inline In Spec
Editors:
Tab Atkins-Bittner (Google)
Elika J. Etemad / fantasai (Invited Expert)

Abstract

A brief description of an alternate model for scroll-snapping.

CSS is a language for describing the rendering of structured documents (such as HTML and XML) on screen, on paper, in speech, etc.

Status of this document

The following features are at-risk, and may be dropped during the CR period:

“At-risk” is a W3C Process term-of-art, and does not necessarily imply that the feature is in danger of being dropped or delayed. It means that the WG believes the feature may have difficulty being interoperably implemented in a timely manner, and marking it as such allows the WG to drop the feature if necessary when transitioning to the Proposed Rec stage, without having to publish a new Candidate Rec without the feature first.

1. Introduction

We think scroll snapping is a great idea, and fully support exposing this functionality through CSS. However, a major weakness of the current spec is the way it conceives snapping on a coordinate model rather than a box model. This requires a lot of manual calculations in figuring out the correct coordinates from the box model; and also makes sensible scroll-snap settings dependent on the relative sizes of the viewport and the snappable contents, causing problems for users are unexpectedly large and/or small screens (a problem commonly ignored by many authors).

This proposal builds off of roc’s model, using an area-snapping model to intelligently handle adaptation to multiple screen sizes. It also adds group alignment as a built-in concept, rather than requiring authors to build one in JavaScript.

2. Use Cases

Use Case 1: Snapping to the start or middle of each box e.g. address book (start) or photo album (middle)
  1. Snapping to 0.25rem above the top of each heading

    :root { scroll-snap-type: proximity; }
    h1, h2, h3, h4, h5, h6 {
      scroll-snap-align: start;
      scroll-snap-margin: 0.25em;
    }
    
  2. Snapping to the center of each photo

    :root { scroll-snap-type: mandatory; }
    img { scroll-snap-align: center; }
    
Use Case 2: Snapping to boxes (or points) in 2D e.g. on a map, where you want to snap points of interest to the center, or a flow-chart diagram, where you want to snap the edges of each box into the visible area. In both cases, you don’t want objects wholly outside the visible area to influence snapping.
  1. Snapping each flow chart entry to within the viewport when it falls near the edge:

    :root {
      scroll-snap-type: proximity;
    }
    li {
      scroll-snap-align: start;
    }
    
  2. Snapping each city on a map to the center of the viewport, but only once it gets near the center in both dimensions:

    :root {
      scroll-snap-type: proximity;
    }
    .city {
      scroll-snap-align: center;
    }
    
Use Case 3: Slideshow, where successive slides are arranged horizontally, and sometimes "detail" slides are placed below the "main" slide for that point.
<div class="slides">
  <div class="slide">...</div>
  <div class="slide">...</div>
  <div class="slide details">
    <div class="slide">...</div>
    <div class="slide">...</div>
  </div>
  <div class="slide">...</div>
</div>
<style>
.slides {
  display: flex;
  flex-flow: row;
  scroll-snap-type: mandatory;
  overflow-x: scroll;
  width: 100vw;
  height: 100vh;
}
.slide {
  scroll-snap-align: start;
  width: 100vw;
  min-height: 100vh;
}
.slide.details {
  display: flex;
  flex-flow: column;
  scroll-snap-type: mandatory;
  overflow-y: scroll;
}
</style>

3. Overview of Change

On the scroll container:

Spec Proposal Priority
scroll-snap-type: none | mandatory | proximity scroll-snap-type: none | [ mandatory | proximity ] || [ x | y | block | inline | both | point] High priority
''scroll-snap-destination: <position>'' ''scroll-snap-padding: [ <length> | <percentage> ]{1,4}''

On the children:

Spec Proposal Priority
''scroll-snap-coordinate: <position>#'' scroll-snap-align: [ none | start | end | center ]{1,2} High priority
n/a ''scroll-snap-margin: <length>{1,4}'' High priority

4. Scroll Snapping Model

This module introduces control over scroll snap positions, which are scroll positions that produce particular alignments of content within a scrollable viewport. Using the scroll-snap-type property on the relevant scroll container, the author can request a particular bias for the viewport to land on a valid snap position after scrolling operations.

Snap positions are specified as a particular alignment (scroll-snap-align) of a box’s scroll snap area (its border bounding box, as modified by scroll-snap-margin) within the scroll container’s snapport (its scrollport, as reduced by scroll-snap-padding). This is conceptually equivalent to specifying the alignment of an alignment subject within an alignment container. A scroll position that satisfies the specified alignment is a valid snap position.

The act of adjusting the scroll position of a scroll container’s scrollport such that it is aligned to a snap position is called snapping, and a scroll container is said to be snapped to a snap position if its scrollport’s scroll position is that snap position and there is no active scrolling operation. The CSS Scroll Snap Module intentionally does not specify nor mandate any precise animations or physics used to enforce snap positions; this is left up to the user agent.

Snap positions only affect the nearest ancestor scroll container on the element’s containing block chain.

5. Capturing Scroll Snap Areas: Properties on the scroll container

5.1. Scroll Snapping Rules: the scroll-snap-type property

Name: scroll-snap-type
Value: none | [ proximity | mandatory ] || [ x | y | block | inline | both | point ]
Initial: none
Applies to: all elements
Inherited: no
Percentages: n/a
Computed value: as specified
Animatable: no

The scroll-snap-type property specifies whether a scroll container is a scroll snap container, how strictly it snaps, and which axes are considered.

We’re considering splitting this into subproperties. Current proposed names are scroll-snap for the current grammar, scroll-snap-affinity for the proximity/mandatory distinction, and scroll-snap-axis for the x/y/etc distinction.

The strictness values (none, proximity, mandatory) specify how strictly snap positions are enforced on the scroll container (by forcing an adjustment to the scroll position). Values are defined as follows:

none
If specified on a scroll container, the scroll container must not snap: all scroll positions are equally valid.

If specified on a non-scroll container, this value has no effect.

proximity
If specified on a scroll container, the scroll container may snap to a valid snap position at the termination of a scroll, at the discretion of the UA given the parameters of the scroll.

If specified on a non-scroll container, this value “traps” descendant boxes’ snap positions, preventing them from affecting any ancestor scroll containers.

mandatory
If specified on a scroll container, the scroll container is required to be snapped to a valid snap position when there are no active scrolling operations. That is, it must snap to a valid snap position at the termination of a scroll, if any such exist. (If none exist, then no snapping occurs.)

If specified on a non-scroll container, this value “traps” descendant boxes’ snap positions, preventing them from affecting any ancestor scroll containers.

A box captures snap positions if it is a scroll container or has a value other than none for scroll-snap-type. If a box’s nearest snap-position capturing ancestor on its containing block chain is a scroll container with a non-none value for scroll-snap-type, that is the box’s scroll snap container. Otherwise, the box has no scroll snap container, and its snap positions do not trigger snapping.

Authors should use mandatory snap positions with consideration of varyingly-sized screens and (if applicable) varying-sized content. In particular, although access to snapped elements larger than the viewport is handled by the UA, if authors assign mandatory snapping to non-adjacent siblings, content in between can become inaccessible in cases where it is longer than the screen.
For example, if an author wishes to force snapping to the top of each section heading, s/he could accomplish this in two ways: snapping the headings
h1, h2, h3, h4, h5, h6 { scroll-snap-align: start; } /* snap headings - but not section content */

or snapping the section elements.

section { scroll-snap-align: start; }                /* snap entire section - including content */

If the author chooses mandatory snapping of the headings, and one section is longer than the viewport, then the reader will have difficulty accessing the content that overflows the screen, because mandatory snapping does not allow the scroll position to rest on the content between the snapped headings.

However, if the author chooses mandatory snapping of the section element (which contains all the content of the section) then the UA can allow the reader to scroll freely through the entire section in the cases where the content is longer than the screen.

The axis values specify what axis(es) are affected by snap positions, and whether snap positions are evaluated independently per axis, or together as a 2D point. Values are defined as follows:

x
The scroll container axis-snaps to snap positions in its horizontal axis only.
y
The scroll container axis-snaps to snap positions in its vertical axis only.
block
The scroll container axis-snaps to snap positions in its block axis only.
inline
The scroll container axis-snaps to snap positions in its inline axis only.
both
The scroll container axis-snaps to snap positions in both of its axises independently (potentially snapping to different elements in each axis).
point
The scroll container point-snaps to snap positions in both axises simultaneously, treating each element’s snap position as a single 2D position (rather than potentially snapping to different elements in each axis).

If no axis value is specified, then the axis is automatically computed:

If the content or layout of the scroll container changes (e.g. content is added, moved, deleted, resized), the UA must re-evaluate, and potentially re-snap if necessary, the resulting scroll position once the positions of the content have restabilized. This can result in no snapping in some cases (e.g. if there are no nearby snap positions for a proximity-snapping scroll container). However, if there was a previously-snapped snap position (associated with the same element) that still exists after such changes, the UA must remain snapped to it—even if the changes would have placed a different snap position closer to the current scroll position. Otherwise, the scroll container must be re-snapped as if the user had scrolled to its current scroll position (as an explicit scroll, if no other scroll operation is active).

5.2. Scroll Snapport: the scroll-snap-padding property

Name: scroll-snap-padding
Value: [ <length> | <percentage> ]{1,4}
Initial: 0
Applies to: scroll containers
Inherited: no
Percentages: relative to the corresponding dimension of the scroll container’s scrollport
Computed value: as specified, with lengths made absolute
Animatable: as length, percentage, or calc

The scroll-snap-padding property defines the scroll snapportthe area of the scrollport that is used as the alignment container for the scroll snap areas when calculating snap positions. Values are interpreted as for padding, and specify inward offsets from each edge of the scrollport.

In this example, points of interest in a map are centered within the portion of the viewport that does not include the toolbar overlay.
map {
  overflow: scroll;
  scroll-snap-type: proximity;
  scroll-snap-padding: 3em 0 0 0;
}
toolbar {
  position: absolute;
  margin: 0.5em;
  top: 0; left: 0; right: 0;
  height: 2em;
}
city {
  scroll-snap-align: center;
}

This property is a shorthand property that sets all of the scroll-snap-padding-* longhands in one declaration.

6. Aligning Scroll Snap Areas: Properties on the scrolling content

6.1. Scroll Snapping Margin: the scroll-snap-margin property

Name: scroll-snap-margin
Value: <length>{1,4}
Initial: 0
Applies to: all elements
Inherited: no
Percentages: n/a
Computed value: as specified, with lengths made absolute
Animatable: as length

The scroll-snap-margin property defines the scroll snap area that is used for snapping this box to the viewport. The <length> values give outsets (interpreted as for margin or border-image-outset). The scroll snap area is the rectangular bounding box of the transformed border box, plus the specified outsets, axis-aligned in the scroll container’s coordinate space.

Note: This ensures that the scroll snap area is always rectangular and axis-aligned to the scroll container’s coordinate space.

This property is a shorthand property that sets all of the scroll-snap-margin-* longhands in one declaration.

6.2. Scroll Snapping Alignment: the scroll-snap-align property

Name: scroll-snap-align
Value: [ none | start | end | center ]{1,2}
Initial: none
Applies to: all elements
Inherited: no
Percentages: n/a
Computed value: two keywords
Animatable: no

The scroll-snap-align property specifies the box’s snap position as an alignment of its snap area (as the alignment subject) within its snap container’s snapport (as the alignment container). The two values specify snapping alignment in the inline axis and block axis, respectively. If only one value is specified, the second value defaults to the same value.

The following example aligns the start edge of the box’s snap area to the start edge of the scroll container’s snapport:
section { scroll-snap-align: start; }

The following example aligns the center of each city to the center of the scroll container’s snapport, snapping only when the city is centered in both axes:

.map { scroll-snap-type: proximity point; }
.map .city { scroll-snap-align: center; }

The following example aligns the center of each photo to the center of the scroll container’s snapport, snapping independently in each axis:

.photos { scroll-snap-type: mandatory both; }
img { scroll-snap-align: center; }

Values are defined as follows:

none
This box does not define a snap position in the specified axis.
start
Start alignment of this box’s scroll snap area within the scroll container’s snapport is a valid snap position in the specified axis.
end
End alignment of this box’s scroll snap area within the scroll container’s snapport is a valid snap position in the specified axis.
center
Center alignment of this box’s scroll snap area within the scroll container’s snapport is a valid snap position in the specified axis.

If the element’s scroll container is point-snapping, and this property does not specify a valid snap position in both axises (that is, it contains none), the element does not contribute any snap positions at all.

For all of these values, the block or inline axis is relative to the element’s parent’s writing mode.

Is this the correct writing mode to compute against? Or should it be the scroll container’s writing mode?

Why no <length> or <position> values?

The values here represent alignments (in the sense of align-self and justify-self), so are consistent with that syntax. We chose to use this simpler syntax without lengths or percentages because the scroll-snap-margin concept already provides length offsets—but does so in a smarter way, that degrades better on small screens (see above) because it provides more information (a box, rather than a point) to the UA. We could have also added lengths here, but it would provide multiple ways to do the same thing, which is additional overhead for implementation, testing, and (most importantly) author learning. It also introduces more room for cascading errors, and guides authors in the wrong direction—away from scroll-snap-margin.

6.2.1. Scoping Valid Snap Positions to Visible Boxes

Since the purpose of scroll snapping is to align content within the viewport for optimal viewing: in all cases, the specified alignment creates a valid snap position only if at least part of the snap area is within the snapport. For example, a snap area is top-aligned to the snapport if its top edge is coincident with the snapport’s top edge; however, this alignment is nonetheless not a valid snap position if the entire snap area is outside the snapport.

Why limit snapping to only when the element is visible? As the WebKit implementers point out, extending a snap edge infinitely across the canvas only allows for snapping gridded layouts, and produces odd behavior for the user when off-screen elements do not align with on-screen elements. (If this requirement is onerous for implementers however, we can default to a gridded behavior and introduce a switch to get smarter behavior.)

6.2.2. Snapping Boxes that Overflow the Scrollport

If the snap area is larger than the snapport in a particular axis, and there are no other snap areas within the snapport that would provide a snap position aligning the overflowing snap area within the snapport, then any scroll position in which the snap area covers the snapport is a valid snap position in that axis. The UA may use the specified alignment as a more precise target for certain scroll operations (e.g. inertial scrolling or explicit paging).

For example, take the third code fragment in the previous example, which had a photo as the area. The author wants mandatory snapping from item to item, but if the item happens to be larger than your viewport, you want to be able to scroll around the whole thing once you’re over it.

Since the snap area is larger than the snapport, while the area fully fills the viewport, the container can be scrolled arbitrarily and will not try to snap back to its aligned position. However, if the container is scrolled such that the area no longer fully fills the viewport in an axis, the area resists outward scrolling until you fling out or pull it sufficiently to trigger snapping to a different snap position.

6.2.3. Unreachable Snap Areas

If a snap position is unreachable as specified, such that aligning to it would require scrolling the scroll container’s viewport past the edge of its scrollable area, the used snap position for this snap area is the position resulting from scrolling as much as possible in each relevant axis toward the desired snap position.

6.3. Scroll Snap Limits: the scroll-snap-stop property

Name: scroll-snap-stop
Value: normal | always
Initial: normal
Applies to: all elements
Inherited: no
Percentages: n/a
Computed value: as specified
Animatable: no

This property specifies whether the snap position absorbs all remaining inertia during an inertial scroll, or allows the inertial scroll to pass multiple snap positions before coming to rest. Values are defined as follows:

normal
A snap position defined by this element does not interfere with the inertia of an inertial scroll that is passing across it, unless it is the landing snap position.
always
A snap position defined by this element, when encountered by an inertial scroll, absorbs all remaining inertia from an inertial scroll, forcing a stop at this snap position, exactly as if the scroll had enough inertia to reach the snap position, but not enough to escape it.

Note: This means that if all snap positions in a scroller have scroll-snap-stop: always, an inertial scroll can only move one snap position per inertial scroll action.

7. Snapping Mechanics

The precise model algorithm to select a snap position to snap to is intentionally left mostly undefined, so that user agents can take into account sophisticated models of user intention and interaction and adjust how they respond over time, to best serve the user.

This section defines some useful concepts to aid in discussing scroll-snapping mechanics, and provides some guidelines for what an effective scroll-snapping strategy might look like. User agents are encouraged to adapt this guidance and apply their own best judgement when defining their own snapping behavior. It also provides a small number of behavior requirements, to ensure a minimum reasonable behavior that authors can depend on when designing their interfaces with scroll-snapping in mind.

7.1. Types of Scrolling Methods

When a page is scrolled, the action is performed with an intended end position and/or an intended direction. Each combination of these two things defines a distinct category of scrolling, which can be treated slightly differently:

explicit scrolling

A scroll is explicit if it has an intended end position, but no intended direction.

This includes methods such as:

  • a panning gesture, released without momentum

  • manipulating the scrollbar "thumb" explicitly

  • programmatically scrolling via APIs such as scrollTo()

  • tabbing through the document’s focusable elements

  • navigating to an anchor within the page

inertial scrolling

A scroll is inertial if it has both an intended end position and an intended direction.

This includes methods such as:

  • a "fling" gesture, released with momentum (the "intended" end position might be implicitly determined by the UA’s scrolling physics, but the strength of the user’s fling still expresses a weak intention about where the scroll should end up)

  • a mousewheel scroll

  • programmatically scrolling via APIs such as scrollBy()

The scroll position that an inertial scroll would naturally land on without further intervention is the natural end-point.

directional scrolling

A scroll is directional if it has an intended direction, but no intended end point.

This includes methods such as:

  • pressing an arrow key on the keyboard

Additionally, because page layouts usually align things vertically and/or horizontally, UAs sometimes axis-lock a scroll when its direction is sufficiently vertical or horizontal. An axis-locked scroll is bound to only scroll along that axis. This prevents, for example, a nearly horizontal fling gesture from gradually drifting up or down as well, because it is very difficult to fling in a precisely horizontal line.

7.2. Axis vs Point-Snapping

This feature is planned to be removed in the next publication in order to reduce the feature-set of Level 1. It is included here for future reference in defining Level 2.

There are two distinct snapping behaviors that a scroll container might engage in:

axis-snapping

If a scroll container is axis-snapping, its descendants indicate a desired scroll position in each axis of the scroll container independently, with no dependent preference for what the other axis’s scroll position should be.

Note: This is the “default” type of snap behavior that most scroll containers will want to use, and so the scroll-snap-type property intentionally defaults to it.

Note: An element in an axis-snapping scroll container can declare two snap positions, one in each axis. If one of the element’s snap positions is chosen in one axis, this has no bearing on the other dimension’s snap positionit might be chosen, or a different element’s snap position might be chosen for that axis, or that axis might not snap at all.

point-snapping

If a scroll container is point-snapping, its descendants indicate a desired scroll position in both axises of the scroll container simultaneously—in other words, some point in the descendant must be aligned to a corresponding point in the scroll container.

This type of snapping behavior is intended for "two-dimensional" panning-type layouts, such as cities on a map (using proximity 2D snap positions to snap a city to the center of the display when it gets close), or a tiled image gallery (using mandatory 2D snap positions to force each image to be centered on the screen). In both of these cases, it would look weird if the horizontal scrolling was aligned to one element while the vertical was aligned to a different element (which is the behavior you’d get if the scroll container was axis-snapping).

7.3. Choosing Snap Positions

A scroll container can have many snap areas scattered throughout its scrollable area. A naive algorithm for selecting a snap position can produce behavior that is unintuitive for users, so care is required when designing a selection algorithm. Here are a few pointers that can aid in the selection process:

Appendix A: Longhands

Physical Longhands for scroll-snap-padding

Name: scroll-snap-padding-top, scroll-snap-padding-right, scroll-snap-padding-bottom, scroll-snap-padding-left
Value: <length> | <percentage>
Initial: 0
Applies to: scroll containers
Inherited: no
Percentages: n/a
Computed value: as specified, with lengths made absolute
Percentage: relative to the corresponding dimension of the scroll container’s scrollport
Animatable: as length, percentage, or calc

These longhands of scroll-snap-padding specify the top, right, bottom, and left edges of the snapport, respectively.

Flow-relative Longhands for scroll-snap-padding

Name: scroll-snap-padding-inline-start, scroll-snap-padding-block-start, scroll-snap-padding-inline-end, scroll-padding-block-end
Value: <length> | <percentage>
Initial: 0
Applies to: scroll containers
Inherited: no
Percentages: relative to the corresponding dimension of the scroll container’s scrollport
Computed value: as specified, with lengths made absolute
Animatable: as length, percentage, or calc

These longhands of scroll-snap-padding specify the block-start, inline-start, block-end, and inline-end edges of the snapport, respectively.

Name: scroll-snap-padding-block, scroll-snap-padding-inline
Value: [ <length> | <percentage> ]{1,2}
Initial: 0
Applies to: all elements
Inherited: no
Percentages: relative to the corresponding dimension of the scroll container’s scrollport
Computed value: as specified, with lengths made absolute
Animatable: as length, percentage, or calc

These shorthands of scroll-snap-padding-block-start + scroll-snap-padding-block-end and scroll-snap-padding-inline-start + scroll-snap-padding-inline-end are longhands of scroll-snap-padding, and specify the block-axis and inline-axis edges of the snapport, respectively.

If two values are specified, the first gives the start value and the second gives the end value.

Physical Longhands for scroll-snap-margin

Name: scroll-snap-margin-top, scroll-snap-margin-right, scroll-snap-margin-bottom, scroll-snap-margin-left
Value: <length>
Initial: 0
Applies to: all elements
Inherited: no
Percentages: n/a
Computed value: as specified, with lengths made absolute
Animatable: as length

These longhands of scroll-snap-margin specify the top, right, bottom, and left edges of the scroll snap area, respectively.

Flow-relative Longhands for scroll-snap-margin

Name: scroll-snap-margin-block-start, scroll-snap-margin-inline-start, scroll-snap-margin-block-end, scroll-snap-margin-inline-end
Value: <length>
Initial: 0
Applies to: all elements
Inherited: no
Percentages: n/a
Computed value: as specified, with lengths made absolute
Animatable: as length

These longhands of scroll-snap-margin specify the block-start, inline-start, block-end, and inline-end edges of the scroll snap area, respectively.

Name: scroll-snap-margin-block, scroll-snap-margin-inline
Value: <length>{1,2}
Initial: 0
Applies to: all elements
Inherited: no
Percentages: n/a Computed value: as specified, with lengths made absolute
Animatable: as length

These shorthands of scroll-snap-margin-block-start + scroll-snap-margin-block-end and scroll-snap-margin-inline-start + scroll-snap-margin-inline-end are longhands of scroll-snap-margin, and specify the block-axis and inline-axis edges of the scroll snap area, respectively. If two values are specified, the first gives the start value and the second gives the end value.

8. Privacy and Security Considerations

This specification does not expose any information whatsoever that is not already exposed to the DOM directly; it just makes scrolling slightly more functional. There are no new privacy or security considerations.

9. Acknowledgements

Many thanks to David Baron, Simon Fraser, Håkon Wium Lie, Edward O’Connor, François Remy, Majid Valpour, potentially some anonymous Microsoft engineers (?), and most especially Robert O’Callahan for their proposals and recommendations, which have been incorporated into this document.

Conformance

Document conventions

Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification.

All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. [RFC2119]

Examples in this specification are introduced with the words “for example” or are set apart from the normative text with class="example", like this:

This is an example of an informative example.

Informative notes begin with the word “Note” and are set apart from the normative text with class="note", like this:

Note, this is an informative note.

Advisements are normative sections styled to evoke special attention and are set apart from other normative text with <strong class="advisement">, like this: UAs MUST provide an accessible alternative.

Conformance classes

Conformance to this specification is defined for three conformance classes:

style sheet
A CSS style sheet.
renderer
A UA that interprets the semantics of a style sheet and renders documents that use them.
authoring tool
A UA that writes a style sheet.

A style sheet is conformant to this specification if all of its statements that use syntax defined in this module are valid according to the generic CSS grammar and the individual grammars of each feature defined in this module.

A renderer is conformant to this specification if, in addition to interpreting the style sheet as defined by the appropriate specifications, it supports all the features defined by this specification by parsing them correctly and rendering the document accordingly. However, the inability of a UA to correctly render a document due to limitations of the device does not make the UA non-conformant. (For example, a UA is not required to render color on a monochrome monitor.)

An authoring tool is conformant to this specification if it writes style sheets that are syntactically correct according to the generic CSS grammar and the individual grammars of each feature in this module, and meet all other conformance requirements of style sheets as described in this module.

Requirements for Responsible Implementation of CSS

The following sections define several conformance requirements for implementing CSS responsibly, in a way that promotes interoperability in the present and future.

Partial Implementations

So that authors can exploit the forward-compatible parsing rules to assign fallback values, CSS renderers must treat as invalid (and ignore as appropriate) any at-rules, properties, property values, keywords, and other syntactic constructs for which they have no usable level of support. In particular, user agents must not selectively ignore unsupported property values and honor supported values in a single multi-value property declaration: if any value is considered invalid (as unsupported values must be), CSS requires that the entire declaration be ignored.

Implementations of Unstable and Proprietary Features

To avoid clashes with future stable CSS features, the CSSWG recommends following best practices for the implementation of unstable features and proprietary extensions to CSS.

Implementations of CR-level Features

Once a specification reaches the Candidate Recommendation stage, implementers should release an unprefixed implementation of any CR-level feature they can demonstrate to be correctly implemented according to spec, and should avoid exposing a prefixed variant of that feature.

To establish and maintain the interoperability of CSS across implementations, the CSS Working Group requests that non-experimental CSS renderers submit an implementation report (and, if necessary, the testcases used for that implementation report) to the W3C before releasing an unprefixed implementation of any CSS features. Testcases submitted to W3C are subject to review and correction by the CSS Working Group.

Further information on submitting testcases and implementation reports can be found from on the CSS Working Group’s website at http://www.w3.org/Style/CSS/Test/. Questions should be directed to the public-css-testsuite@w3.org mailing list.

Index

Terms defined by this specification

Terms defined by reference

References

Normative References

[CSS-ALIGN-3]
Elika Etemad; Tab Atkins Jr.. CSS Box Alignment Module Level 3. 14 June 2016. WD. URL: https://drafts.csswg.org/css-align/
[CSS-BACKGROUNDS-3]
CSS Backgrounds and Borders Module Level 3 URL: https://drafts.csswg.org/css-backgrounds-3/
[CSS-CASCADE-4]
Elika Etemad; Tab Atkins Jr.. CSS Cascading and Inheritance Level 4. 14 January 2016. CR. URL: http://dev.w3.org/csswg/css-cascade/
[CSS-DISPLAY-3]
Tab Atkins Jr.; Elika Etemad. CSS Display Module Level 3. 15 October 2015. WD. URL: http://dev.w3.org/csswg/css-display/
[CSS-OVERFLOW-3]
David Baron; Florian Rivoal. CSS Overflow Module Level 3. 31 May 2016. WD. URL: http://drafts.csswg.org/css-overflow/
[CSS-OVERFLOW-4]
CSS Overflow Module Level 4 URL: https://drafts.csswg.org/css-overflow-4/
[CSS-VALUES]
Tab Atkins Jr.; Elika Etemad. CSS Values and Units Module Level 3. 11 June 2015. CR. URL: http://dev.w3.org/csswg/css-values/
[CSS-WRITING-MODES-3]
Elika Etemad; Koji Ishii. CSS Writing Modes Level 3. 15 December 2015. CR. URL: http://dev.w3.org/csswg/css-writing-modes-3/
[CSS2]
Bert Bos; et al. Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification. 7 June 2011. REC. URL: https://www.w3.org/TR/CSS2
[CSSOM-VIEW-1]
Simon Pieters. CSSOM View Module. 17 March 2016. WD. URL: https://drafts.csswg.org/cssom-view/
[RFC2119]
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://tools.ietf.org/html/rfc2119
[SELECTORS-4]
Selectors Level 4 URL: https://drafts.csswg.org/selectors-4/

Property Index

Name Value Initial Applies to Inh. %ages Media Animatable Computed value Percentage
scroll-snap-type none | [ proximity | mandatory ] || [ x | y | block | inline | both | point ] none all elements no n/a interactive no as specified
scroll-snap-padding [ <length> | <percentage> ]{1,4} 0 scroll containers no relative to the corresponding dimension of the scroll container’s scrollport interactive as length, percentage, or calc as specified, with lengths made absolute
scroll-snap-margin <length>{1,4} 0 all elements no n/a interactive as length as specified, with lengths made absolute
scroll-snap-align [ none | start | end | center ]{1,2} none all elements no n/a interactive no two keywords
scroll-snap-stop normal | always normal all elements no n/a interactive no as specified
scroll-snap-padding-top <length> | <percentage> 0 scroll containers no n/a interactive as length, percentage, or calc as specified, with lengths made absolute relative to the corresponding dimension of the scroll container’s scrollport
scroll-snap-padding-right <length> | <percentage> 0 scroll containers no n/a interactive as length, percentage, or calc as specified, with lengths made absolute relative to the corresponding dimension of the scroll container’s scrollport
scroll-snap-padding-bottom <length> | <percentage> 0 scroll containers no n/a interactive as length, percentage, or calc as specified, with lengths made absolute relative to the corresponding dimension of the scroll container’s scrollport
scroll-snap-padding-left <length> | <percentage> 0 scroll containers no n/a interactive as length, percentage, or calc as specified, with lengths made absolute relative to the corresponding dimension of the scroll container’s scrollport
scroll-snap-padding-inline-start <length> | <percentage> 0 scroll containers no relative to the corresponding dimension of the scroll container’s scrollport interactive as length, percentage, or calc as specified, with lengths made absolute
scroll-snap-padding-block-start <length> | <percentage> 0 scroll containers no relative to the corresponding dimension of the scroll container’s scrollport interactive as length, percentage, or calc as specified, with lengths made absolute
scroll-snap-padding-inline-end <length> | <percentage> 0 scroll containers no relative to the corresponding dimension of the scroll container’s scrollport interactive as length, percentage, or calc as specified, with lengths made absolute
scroll-padding-block-end <length> | <percentage> 0 scroll containers no relative to the corresponding dimension of the scroll container’s scrollport interactive as length, percentage, or calc as specified, with lengths made absolute
scroll-snap-padding-block [ <length> | <percentage> ]{1,2} 0 all elements no relative to the corresponding dimension of the scroll container’s scrollport interactive as length, percentage, or calc as specified, with lengths made absolute
scroll-snap-padding-inline [ <length> | <percentage> ]{1,2} 0 all elements no relative to the corresponding dimension of the scroll container’s scrollport interactive as length, percentage, or calc as specified, with lengths made absolute
scroll-snap-margin-top <length> 0 all elements no n/a interactive as length as specified, with lengths made absolute
scroll-snap-margin-right <length> 0 all elements no n/a interactive as length as specified, with lengths made absolute
scroll-snap-margin-bottom <length> 0 all elements no n/a interactive as length as specified, with lengths made absolute
scroll-snap-margin-left <length> 0 all elements no n/a interactive as length as specified, with lengths made absolute
scroll-snap-margin-block-start <length> 0 all elements no n/a interactive as length as specified, with lengths made absolute
scroll-snap-margin-inline-start <length> 0 all elements no n/a interactive as length as specified, with lengths made absolute
scroll-snap-margin-block-end <length> 0 all elements no n/a interactive as length as specified, with lengths made absolute
scroll-snap-margin-inline-end <length> 0 all elements no n/a interactive as length as specified, with lengths made absolute
scroll-snap-margin-block <length>{1,2} 0 all elements no n/a interactive as length as specified, with lengths made absolute
scroll-snap-margin-inline <length>{1,2} 0 all elements no n/a interactive as length as specified, with lengths made absolute

Issues Index

We’re considering splitting this into subproperties. Current proposed names are scroll-snap for the current grammar, scroll-snap-affinity for the proximity/mandatory distinction, and scroll-snap-axis for the x/y/etc distinction.
Is this the correct writing mode to compute against? Or should it be the scroll container’s writing mode?
This feature is planned to be removed in the next publication in order to reduce the feature-set of Level 1. It is included here for future reference in defining Level 2.