CSS scroll-margin-inline-end Property
Description
The scroll-margin-inline-end property defines an extra offset on the inline-end side of an element that the browser uses when bringing that element into view via scrolling or when snapping to it. It does not change the element’s position in normal layout or its computed box model; instead, it influences the scroll target alignment by adding space between the element’s border edge and the scroller’s inner edge on the element’s inline-end side. This makes it useful for adjusting how “close” a target appears to the scroller’s edge after a programmatic scroll or a snap operation without altering surrounding flow.
Because scroll-margin-inline-end is a logical property, its effect follows writing mode and directionality: what counts as the inline end varies with the element’s writing-mode and direction. In a horizontal LTR context the inline end corresponds to the physical right side; in RTL it becomes the physical left. In vertical writing modes the inline axis is orthogonal to the block axis, so the “inline end” maps to a different physical side accordingly. This logical behavior makes scroll-margin-inline-end a convenient way to author cross-directional spacing for scroll targets without writing separate rules for each language or layout orientation.
You’ll commonly use scroll-margin-inline-end alongside the broader scroll-margin shorthands and related scroll properties. For example, the values set by scroll-margin or scroll-margin-inline can affect both inline sides and block sides together, while margin-inline-end is the ordinary layout margin that moves boxes in the flow (so it’s not interchangeable with scroll margins). For scroll-snapping scenarios you often combine a scroll margin with scroll-snap-align to control which element is treated as the snap target and where it finishes relative to the container, and you may consider the scroller’s interior spacing via scroll-padding-inline to balance offsets between container padding and target scroll margins.
Practical use cases include ensuring anchored content isn’t obscured by fixed-position UI (headers, toolbars) after a jump-to-anchor, creating consistent spacing when snapping horizontally between items, or fine-tuning the visual alignment of elements brought into view programmatically. Remember that this property only affects how the scrolling algorithm calculates the final snapped/visible position of the element; it doesn’t create visual gaps in normal layout or change hit-testing for surrounding content.
Definition
- Initial value
- 0
- Applies to
- all elements
- Inherited
- no
- Computed value
- as specified
- Animatable
- by computed value type
- JavaScript syntax
- object.style.scrolllMarginInlineEnd
Interactive Demo
Syntax
scroll-margin-inline-end: >length<
Values
- >length<An outset from the corresponding edge of the scroll container.
Example
Browser Support
The following information will show you the current browser support for the CSS scroll-margin-inline-end property. Hover over a browser icon to see the version that first introduced support for this CSS property.
This property is supported by all modern browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 1st January 2026
