Scroll-snap-stop - CSS Property

scroll-snap-stop

Summary of characteristics of the scroll-snap-stop property

Quick description
Allows you to force scrolling to stop on certain elements (Scroll-Snap).
Status
Standard
Applies to
All elements.
Usable for
HTML
Predefined values
normal | always
Percentages
Not applicable.
Initial value
normal
Inherited by default
No.
Discrète: during an animation, the scroll-snap-stop property passes from one value to another without transition.
Single: single value (no order).
W3C Module
CSS Scroll Snap Module
Document status: CR (Candidate Recommendation)

Syntax diagram of scroll-snap-stop.

scroll-snap-stop - Syntax DiagramSyntax diagram of the scroll-snap-stop CSS property. See stylescss.free.fr for details. normal normal always alwaysscroll-snap-stop:;scroll-snap-stop:;
Syntax diagram of the scroll-snap-stop property.
The links in the diagram provide more details about the values.

Description of the scroll-snap-stop property.

The `scroll-snap-stop` property in the context of a scroll snap container. It allows you to force the scrolling to stop on specific elements. This is especially useful on touchscreens: users often scroll more than they intend and risk missing important elements, forcing them to go back.

scroll-snap-stop must be applied to the scrolling content elements on which we want to force the stop.

The example below is a partial list of CSS properties, classified by modules. The property scroll-snap-stop allows stopping the scrolling on each of the module titles. The effect will only be truly visible on a terminal with a touchscreen (scrolling by swiping with a finger), or equipped with a notepad. However, the ergonomics are not perfect because it is difficult to scroll long blocks like "CSS Backgrounds and borders module".

Compositing and Blending

isolation
mix-blend-mode

CSS Fragmentation Module

break-after
break-before
break-inside
orphans
widows

CSS Color Module

opacity

CSS Color Adjustment Module

color-scheme
forced-color-adjust
print-color-adjust

CSS Containment Module

container
container-name
container-type
content-visibility

CSS Ruby Annotation Layout Module

ruby-merge
ruby-overhang
ruby-position

CSS Scroll Snap Module

scroll-margin-block
scroll-margin-block-end
scroll-margin-block-start
scroll-margin-bottom
scroll-margin-inline
scroll-margin-inline-end
scroll-margin-inline-start
scroll-margin-left
scroll-margin-right
scroll-margin-top
scroll-padding
scroll-padding-block
scroll-padding-block-end
scroll-padding-block-start
scroll-padding-bottom
scroll-padding-inline
scroll-padding-inline-end
scroll-padding-inline-start
scroll-padding-left
scroll-padding-right
scroll-padding-top
scroll-snap-align
scroll-snap-stop
scroll-snap-type
scoll-snap-stop:normal;

Compositing and Blending

isolation
mix-blend-mode

CSS Fragmentation Module

break-after
break-before
break-inside
orphans
widows

CSS Color Module

opacity

CSS Color Adjustment Module

color-scheme
forced-color-adjust
print-color-adjust

CSS Containment Module

container
container-name
container-type
content-visibility

CSS Ruby Annotation Layout Module

ruby-merge
ruby-overhang
ruby-position

CSS Scroll Snap Module

scroll-margin-block
scroll-margin-block-end
scroll-margin-block-start
scroll-margin-bottom
scroll-margin-inline
scroll-margin-inline-end
scroll-margin-inline-start
scroll-margin-left
scroll-margin-right
scroll-margin-top
scroll-padding
scroll-padding-block
scroll-padding-block-end
scroll-padding-block-start
scroll-padding-bottom
scroll-padding-inline
scroll-padding-inline-end
scroll-padding-inline-start
scroll-padding-left
scroll-padding-right
scroll-padding-top
scroll-snap-align
scroll-snap-stop
scroll-snap-type
scoll-snap-stop:always;


Also see the following properties:

Overflow management, when the content is too large for the dimensions imposed on the element.
Defines the main characteristics of a scroll snap. To apply to a scrolling container.
Defines the alignment of the elements used as snaps in relation to the display window (scroll Snap technique).
Defines the scroll margins of the scroll window in the context Scroll Snap.
Sets the interior margins of the scroll window.

Values for scroll-snap-stop.

  • scroll-snap-stop: normal;

    When scrolling through the container, some snap point may be skipped.

  • scroll-snap-stop: always;

    The elements targeted by the scroll-snap-stop property with the value always will block scrolling.

  • scroll-snap-stop: initial; (normal) scroll-snap-stop: inherit; scroll-snap-stop: revert; scroll-snap-stop: revertLayer; scroll-snap-stop: unset;

    See the following pages for more details: initial, inherit, revert, revert-layer, unset.

Animation of the scroll-snap-stop property.

The property scroll-snap-stop can be animated. But since its effect is only visible when scrolling the content, the visual rendering of the animation is nonexistent.

Access the scroll-snap-stop property via a program

With Javascript, change the value of scroll-snap-stop.

In JavaScript, here is how to modify the value of scroll-snap-stop. Two syntax examples are given: the first with a typical CSS notation, in kebab-case, and the second with JavaScript notation, in camel-case.

Javascript
let el = document.getElementById('id'); el.style['scroll-snap-stop'] = 'always'; // or let el = document.getElementById('id'); el.style.scrollSnapStop = 'always';

With Javascript, read the value of scroll-snap-stop.

When the property has been applied to the element itself via its style attribute, the code below retrieves its value, but not if it has been set through a CSS selector.

Javascript
let el = document.getElementById('id'); let value = el.style['scroll-snap-stop']; // or let el = document.getElementById('id'); let value = el.style.scrollSnapStop;

With Javascript, read the computed value of scroll-snap-stop.

The computed value is the one that results from the value assigned to the element, and from the possible consideration of inherited values. Failing that, it will be the initial value of the property: normal in the case of scroll-snap-stop.

Javascript
let el = document.getElementById('id'); let value = window.getComputedStyle(el).getPropertyValue('scroll-snap-stop');

With JQuery, change the value of scroll-snap-stop.

JQuery also offers syntaxes for manipulating the property scroll-snap-stop. They are shorter than those of Javascript.

JQuery

$('#id').css('scroll-snap-stop', 'always');
// or
$('#id').css('scrollSnapStop', 'always');

With JQuery, read the computed value of scroll-snap-stop.

JQuery
let value = $('#id').css('scroll-snap-stop');

Other code examples.

Other examples of Javascript and JQuery code are given on the page Javascript and CSS. All of this code deals with the manipulation of CSS styles with Javascript or JQuery.

Test it yourself.

The buttons below apply the entered value to the property scroll-snap-stop and then display either the value as it was applied or the computed value. In the case of scroll-snap-stop, there will be no difference between these two values since the property only accepts predefined values. However, if you try to assign a non-existent value, the first value will be empty, while the second will be the initial value.

Simulator.

Let us recall that the effect of the property scroll-snap-stop is hardly noticeable, even invisible, when scrolling is done with a mouse. Use a terminal with a touchscreen that allows scrolling the content with your finger.

scroll-snap-stop :

Compositing and Blending

isolation
mix-blend-mode

CSS Fragmentation Module

break-after
break-before
break-inside
orphans
widows

CSS Color Module

opacity

CSS Color Adjustment Module

color-scheme
forced-color-adjust
print-color-adjust

CSS Containment Module

container
container-name
container-type
content-visibility

CSS Ruby Annotation Layout Module

ruby-merge
ruby-overhang
ruby-position

CSS Scroll Snap Module

scroll-margin-block
scroll-margin-block-end
scroll-margin-block-start
scroll-margin-bottom
scroll-margin-inline
scroll-margin-inline-end
scroll-margin-inline-start
scroll-margin-left
scroll-margin-right
scroll-margin-top
scroll-padding
scroll-padding-block
scroll-padding-block-end
scroll-padding-block-start
scroll-padding-bottom
scroll-padding-inline
scroll-padding-inline-end
scroll-padding-inline-start
scroll-padding-left
scroll-padding-right
scroll-padding-top
scroll-snap-align
scroll-snap-stop
scroll-snap-type

Browsers compatibility with scroll-snap-stop.

The compatibility of current browsers with scroll-snap-stop is correct. There are still some issues with marginal or obsolete browsers.

Column 1
Support of scroll snap (when handling the scroll bars, the content stops at relevant points).
Column 2
Support for the scroll-snap-stop property to define which elements are important for the scrolling to stop.
1
Scroll Snap
2
scroll-snap-stop
property
Estimated overall support.
96%
94%

Browsers on computers :

Mobile browsers :

Outdated or marginal browsers :

Internet Explorer

UC Browser pour Androïd

Opéra Mobile

QQ Browser

Baidu Browser

Opéra

Samsung Internet

Firefox pour Androïd

Edge

Firefox

Chrome pour Androïd

Androïd Brower

Safari

Safari sur IOS

Chrome

KaiOS Browser

Opéra mini

Historic of the scroll-snap-stop property.

  • CSS Scroll Snap Module - Level 1

    This specification module defines the features regarding scrolling with snap positions. In other words, content-aligned scrolling, to prevent, for example, an image from being cut off at the top or bottom of its container.

    Regarding scroll-snap-stop. First introduction to the scroll-snap-stop property.
    WD
    March 26, 2015
    Working Draft.
    CR
    October 20, 2016
    Candidate Recommendation.
    PR
    REC

See also, regarding scrolling with snapping.

Scrolling with snapping is described in the CSS Scroll Snap Module. The property scroll-snap-stop and all those related to the subject are also present in this module:

Properties:

scroll-margin
Defines the scroll margins of the scroll window in the context Scroll Snap.
scroll-margin-block
Sets the scroll window margins for the start and end of blocks.
scroll-margin-block-end
Sets the scroll window margins for end of blocks.
scroll-margin-block-start
Sets the scroll window margins for the start of blocks.
scroll-margin-bottom
Sets the margins at the bottom of the scroll window in the context of scrolling with snapping.
scroll-margin-inline
Sets the scroll window margins for the start and end of lines.
scroll-margin-inline-end
Sets the scroll window margins for the end of lines.
scroll-margin-inline-start
Sets the scroll window margins for the start of lines.
scroll-margin-left
Sets the margins at the top of the scroll window in the context of scrolling with snapping.
scroll-margin-right
Sets the right margins of the scroll window in the context of scroll snapping.
scroll-margin-top
Sets the top margins of the scroll window in the context of scroll snapping.
scroll-padding
Sets the interior margins of the scroll window.
scroll-padding-block
Sets the inner margin of the scroll window, for the start and end of blocks.
scroll-padding-block-end
Sets the inner margin of the scroll window, for the start of blocks.
scroll-padding-block-start
Sets the inner margin of the scroll window, for the start of blocks.
scroll-padding-bottom
Sets the bottom padding of the scroll window.
scroll-padding-inline
Sets the inner margin of the scroll window, for the start and end of lines.
scroll-padding-inline-end
Sets the inner margin of the scroll window, for the end of lines.
scroll-padding-inline-start
Sets the inner margin of the scroll window, for the start of lines.
scroll-padding-left
Sets the left padding of the scroll window.
scroll-padding-right
Sets the right inner margin of the scroll window.
scroll-padding-top
Sets the top padding for the scroll window.
scroll-snap-align
Defines the alignment of the elements used as snaps in relation to the display window (scroll Snap technique).
Scroll-snap-stop
Allows you to force scrolling to stop on certain elements (Scroll-Snap).
scroll-snap-type
Defines the main characteristics of a scroll snap. To apply to a scrolling container.