CSS scroll-margin Property Last Updated : 30 Jun, 2022 Comments Improve Suggest changes Like Article Like Report The scroll-margin property is used to set all the scroll margins of an element at once. The value specified for the scroll-margin determines how much of the page that is primarily outside the support should remain visible. Hence, the scroll-margin values represent outsets that define the scroll snap area that is used for snapping this box to the support. Syntax: scroll-margin: length /* Or */ scroll-margin: 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 exp: px, em, vh, etc.Global_Values: This property refers to the global values like inherit, initial, unset, etc. Note: scroll-margin doesn't accept percentage value as the length. Example: In this example, you can see the effect of scroll-margin by scrolling to a point partway between two of the “interfaces” of the example's content. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> .scroll { width: 350px; height: 350px; text-align: left; box-sizing: border-box; display: flex; overflow-x: scroll; scroll-snap-type: x mandatory; } .scroll > div { flex: 0 0 350px; width: 350px; font-size: 50px; display: flex; align-items: center; justify-content: center; scroll-snap-align: start; } /* Scroller will give 2rem margin from left */ .scroll > div:nth-child(even) { background-color: rgb(77, 238, 184); color: #fff; scroll-margin: 2rem; } /* Scroller will give 5rem margin from left */ .scroll > div:nth-child(odd) { background-color: #2dc06a; color: #fff; scroll-margin: 5rem; } </style> </head> <body> <div class="scroll"> <div>Geeks</div> <div>for</div> <div>Geeks</div> </div> </body> </html> Output: When scrolling past the middle child elements, the scrolling will snap to 2rem outside the left edge of the even child div, and 3rem outside the left edge of the odd child div. Supported Browsers: Chrome 69Firefox 90Edge 79Safari 14.1Opera 56 Comment More infoAdvertise with us Next Article CSS scroll-margin Property T thacker_shahid Follow Improve Article Tags : Web Technologies CSS CSS-Properties Similar Reads CSS scroll-margin-left property The scroll-margin-left property is used to set all the scroll margins to the left of an element at once. The value specified for the scroll-margin-left determines how much of the page that is primarily outside the support should remain visible.Hence, the scroll-margin-left values represent outsets t 2 min read CSS scroll-margin-block property The scroll-margin-block property is used to set all the scroll margins to the start and end of a scroll element at once. This property is shorthand for the scroll-margin-block-start and scroll-margin-block-end property.The selection of the start and end sides depends upon the writing mode. The start 2 min read CSS scroll-margin-right property The scroll-margin-right property is used to set all the scroll margins to the right of an element at once. The value specified for the scroll-margin-right determines how much of the page that is primarily outside the support should remain visible.Hence, the scroll-margin-right values represent outse 1 min read CSS scroll-margin-inline Property The scroll-margin-inline property is used to set all the scroll margins to the start and end of a scroll element at once. This property is shorthand for the scroll-margin-inline-start and scroll-margin-inline-end property. The selection of the start and end sides depends upon the writing mode. The s 2 min read CSS scroll-margin-bottom Property The scroll-margin-bottom property is used to set all the scroll margins to the bottom of an element at once. The value specified for the scroll-margin-bottom determines how much of the page that is primarily outside the support should remain visible. Hence, the scroll-margin-bottom values represent 2 min read CSS margin-top Property The margin-top property in CSS is used to set the top margin of an element. It sets the margin area on the top of the element. The default value of the margin-top property is 0. Syntax:margin-top: length|auto|initial|inherit;Property values:length: It is used to specify the length of the margin with 4 min read 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. Syntaxscroll-margin-block-end: lengt 2 min read CSS scroll-margin-inline-end property The scroll-margin-inline-end property is used to set all the scroll margins to the end of the inline dimension of a scroll element at once. The selection of the end side depends upon the writing mode. The end side is the right side for the horizontal-tb writing mode and bottom or top side for the ve 2 min read CSS margin-right Property The margin-right property in CSS is used to set the right margin of an element. It sets the margin area on the right side of the element. Negative values are also allowed. The default value of the margin-right property is zero. Syntax:margin-right: length|auto|initial|inherit;Property Value:length: 3 min read CSS | shape-margin Property The shape-margin property is used to set the margin of a shape created by the shape-outside property. This margin is used to adjust the space between the edges of the shape and the surrounding content. Syntax: shape-margin: <length> | <percentage> Property Values: length: It is used to s 2 min read Like