Scroll-snap-align - CSS Property

scroll-snap-align

Summary of characteristics of the scroll-snap-align property

Quick description
Defines the alignment of the elements used as snaps in relation to the display window (scroll Snap technique).
Status
Standard
Applies to
All elements.
Usable for
HTML
Predefined values
none | start | center | end
Percentages
Not applicable.
Initial value
none
Inherited by default
No.
Discrète: during an animation, the scroll-snap-align property passes from one value to another without transition.
Per grammar: serialization in the order of syntax.
W3C Module
CSS Scroll Snap Module
Document status: CR (Candidate Recommendation)

Syntax diagram of scroll-snap-align.

scroll-snap-align - Syntax DiagramSyntax diagram of the scroll-snap-align CSS property. Defines the alignment of elements (snap scrolling). none none start start end end center center {1,2} {1,2}scroll-snap-align:;scroll-snap-align:;
Syntax diagram of the scroll-snap-align property.
The links in the diagram provide more details about the values.
Download the diagram in SVG.

Description of the scroll-snap-align property.

The property scroll-snap-align operates within the context of scrolling with snapping (see our tutorial on scrolling with snaps). It defines how the element that serves as a snap point should be aligned relative to the viewport.

scroll-snap-align is used on elements that serve as attachment points.


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).
Allows you to force scrolling to stop on certain elements (Scroll-Snap).
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-align.

  • scroll-snap-align: none;

    The element is not considered a snap point. If no content element is defined as a snap point, scrolling will occur in the usual manner, without adjustment.

    1
    2
    3
    4
    5

    scroll-snap-align:none;

  • scroll-snap-align: start;

    The start of the element aligns with the start of the viewport. The start of the element depends on the writing mode, depending on the language. See our explanations on writing modes.
    So here is what the start value corresponds to for the main languages.

    Horizontal scrolling
    scroll-snap-type:x;
    Vertical scrolling
    scroll-snap-type:y;
    Latin languagesLeftTop
    Arabic languagesRightTop
    CJK langagesRightTop
    Mongolian languagesLeftTop
    HebrewRightBottom

    In the examples below, the hooks are aligned to start, so to the left for Latin languages, and to the right for Arabic languages (second example), although scroll-snap-align is still set to start.

    Latin languages
    Latin languages
    Latin languages
    Latin languages
    Latin languages
    اللغة العربية
    اللغة العربية
    اللغة العربية
    اللغة العربية
    اللغة العربية
  • scroll-snap-align: end;

    With the value end, the end of the element aligns with the end of the viewport. Depending on the language, the value end corresponds to:

    Horizontal scrolling
    scroll-snap-type:x;
    Vertical scrolling
    scroll-snap-type:y;
    Latin languagesRightBottom
    Arabic languagesLeftBottom
    CJK langagesLeftBottom
    Mongolian languagesRightBottom
    HebrewLeftTop

     

    Latin languages
    Latin languages
    Latin languages
    Latin languages
    Latin languages
    اللغة العربية
    اللغة العربية
    اللغة العربية
    اللغة العربية
    اللغة العربية
  • scroll-snap-align: center;

    The center of the element aligns with the center of the viewport. This value is not dependent on the writing mode, as the center is the same regardless of the language.

    1
    2
    3
    4
    5
  • scroll-snap-align: start center;

    In principle, the syntax of scroll-snap-align expects two values. This is necessary when it is necessary to distinguish the direction of the blocks (first value) from the direction of the lines (second value). When only one value is specified, it applies to both directions.

    The example below shows what happens with center alignment in the line direction (horizontal) and start alignment in the block direction (vertical).

    A1
    A2
    A3
    A4
    A5
    B1
    B2
    B3
    B4
    B5
    C1
    C2
    C3
    C4
    C5
    D1
    D2
    D3
    D4
    D5
    E1
    E2
    E3
    E4
    E5
  • scroll-snap-align: initial; (none) scroll-snap-align: inherit; scroll-snap-align: revert; scroll-snap-align: revertLayer; scroll-snap-align: unset;

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

Animation of the scroll-snap-align property.

The property scroll-snap-align can be animated. Its values being non-numeric, the property switches abruptly from one value to another.

Simulator.

To observe the effect of the scroll-snap-align property and its different values, scroll through the content using the scroll bar or the mouse wheel on a PC, or by swiping on a touchscreen.

scroll-snap-align :
1
2
3
4
5
6
7
8
9
10

Browsers compatibility with scroll-snap-align.

Support for scroll-snap-align is good on all current browsers.

Column 1
Support of scroll snap (when handling the scroll bars, the content stops at relevant points).
Column 2
Support for the property scroll-snap-align which defines whether the snap occurs at the start, center, or end of the element.
1
Scroll Snap
2
scroll-snap-align
property
Estimated overall support.
96%
95%

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-align 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-align. First introduction to the scroll-snap-align 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-align 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.