CSS scroll-margin-block-end property

The scroll-margin-block-end property is used to set all the scroll margins to the end side of a scroll element at once. This property defines the margin of the scroll snap area at the end of the block dimension that is used for snapping this box to the snap port. 


scroll-margin-block-end: length

/* Or */

scroll-margin-block-end: Global_Values

Property values: This property accepts two properties mentioned above and described below:

  • length: This property refers to the values defined with length units like em, px, rem, vh, etc.
  • Global_Values: This property refers to the global values like inherit, initial, unset, etc.

Note: scroll-margin-block-end doesn’t accept percentage value as the length.

Example: In this example, you can see the effect of scroll-margin-block-end by scrolling to a point partway between two of the “interfaces” of the example’s content.






<!DOCTYPE html>
        .interfaces {
              scroll-snap-align: end none;
              display: flex;
              align-items: center;
              justify-content: center;
              font-size: 60px;
              color: white;
        .doc {
              width: 300px;
              overflow-x: hidden;
              overflow-y: auto;
              white-space: nowrap;
              scroll-snap-type:y mandatory;
    <div class="doc">
        <div class="interfaces" style=
              "background-color: rgb(178, 248, 16); 
              scroll-margin-block-end: 90px;">
              Geek 1
        <div class="interfaces" style=
              "color: black; 
              scroll-margin-block-end: 90px;">
              Geek 2
        <div class="interfaces" style=
              "background-color: green; 
              scroll-margin-block-end: 90px;">
              Geek 3
        <div class="interfaces" style=
              "color: green; 
              scroll-margin-block-end: 90px;">
              Geek 4
        <div class="interfaces" style=
              "background-color: rgb(34, 177, 34); 
              scroll-margin-block-end: 90px;">
              Geek 5
        <div class="interfaces" style=
              "background-color: rgb(108, 216, 162); 
              scroll-margin-block-end: 90px;">
              Geek 6


Output: This example shows a snapping area of 90px on scrolling.

Supported Browsers:

  • Chrome
  • Opera
  • Edge
  • Firefox

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.