Skip to content
Related Articles

Related Articles

Improve Article

CSS scroll-margin-block-start property

  • Last Updated : 06 Sep, 2020

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


scroll-margin-block-start: length

/* Or */

scroll-margin-block-start: 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-start doesn’t accept percentage value as the length.

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


<!DOCTYPE html>
        .interfaces {
            scroll-snap-align: start none;
            box-sizing: border-box;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 60px;
            color: white;
        .Container {
            width: 300px;
            overflow-x: hidden;
            overflow-y: auto;
            white-space: nowrap;
            scroll-snap-type: y mandatory;
    <div class="Container">
        <div class="interfaces" style=
            "background-color: rgb(117, 228, 27); 
            scroll-margin-block-start: 80px;">
            Geeks 1
        <div class="interfaces" style=
            "background-color: green; 
            scroll-margin-block-start: 50px;">
            for 2
        <div class="interfaces" style=
            "color: black; 
            scroll-margin-block-start: 100px;">
            Geeks 3
        <div class="interfaces" 
            style="background-color: rgb(60, 184, 126); 
            scroll-margin-block-start: 80px;">
            for 4
        <div class="interfaces" style=
            "background-color: rgb(30, 253, 30); 
            scroll-margin-block-start: 80px;">
            Geeks 5


Supported Browsers:

  • Firefox
  • Chrome
  • Opera
  • Edge

My Personal Notes arrow_drop_up
Recommended Articles
Page :