CSS | Scroll Padding top

The Scroll Padding top is an inbuilt property in Scroll Snap module. This property set the scroll padding top longhand. This property acts as a magnet on the top of the sliding element that stick to the top of the view-port and stop the scrolling(forcefully) in that place.

The Scroll Padding property is optional, this property is used when the Scroll Snap type property is set to none.


scroll-padding-top: [  length percentage | auto ]

Property Values: This property accept two property mentioned above and described below:

  • length-percentage: This property works same as other padding property contains the length in any specific unit for padding.
  • auto: This property leaves some spaces for padding determined by browsers.

Example: Below example illustrates the Scroll Padding top property:





<!DOCTYPE html> 
        CSS Scroll Padding top
        h1 { 
            color: green; 
            border:2px solid black;
        .container { 
            width: 500px; 
            height: 200px; 
            margin-left: auto; 
            margin-right: auto; 
            border: 2px solid black; 
            overflow: scroll; 
            position: relative; 
        .element { 
            width: 480px; 
            height: 180px; 
            scroll-snap-align: start; 
            scroll-snap-stop: normal; 
            color: white; 
            font-size: 50px; 
            display: flex; 
            justify-content: center; 
            align-items: center; 
        .y-mandatory { 
            scroll-snap-type: y mandatory;
                        /* scroll-padding: top right bottom left */ 
            scroll-padding-top: 50px;
        .element:nth-child(1) { 
        .element:nth-child(2) { 
        .element:nth-child(3) { 
        <h4>CSS Scroll Padding top</h4
        <div class="container y-scroll y-mandatory"
            <div class="wrapper"
                <div class="element"></div
                <div class="element"></div
                <div class="element"></div



Supported Browsers: The browsers supported by CSS Scroll Padding top are listed below:

  • Google Chrome 69
  • Internet Explorer 11
  • Firefox 68
  • Safari 11

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.