Favorites

HTML onscrollsnapchanging Event Attribute

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
onscrollsnapchanging
HTML Event AttributeThis event attribute is supported in some modern browsers, but not all.
Updated 22nd November 2026

Description

The onscrollsnapchanging event attribute runs a script on a scroll snap container when the browser picks a new pending snap target during a scroll. It fires while the user is still scrolling, as soon as the element that will be snapped to changes, so the page can give immediate feedback.

Like onscrollsnapchange, the event is a SnapEvent with the properties snapTargetBlock and snapTargetInline. The pending target can still change before the scroll ends, so use scrollsnapchange for actions that should only happen once the scroll has settled.

Syntax

<element onscrollsnapchanging="script">

Values

  • scriptThe name of the script to use when the event has been triggered.

Example

<!DOCTYPE html>
<html>
<head>
<title>onscrollsnapchanging event</title>
<style>
#scroller {
display: flex;
width: 300px;
overflow-x: auto;
scroll-snap-type: x mandatory;
}
#scroller div {
flex: 0 0 100%;
height: 120px;
scroll-snap-align: start;
background: #dde3ff;
}
#scroller div:nth-child(2) { background: #c9d2ff; }
</style>
</head>
<body>
<div id="scroller" onscrollsnapchanging="document.getElementById('info').textContent = 'Will snap to: ' + event.snapTargetInline.textContent">
<div>Slide 1</div><div>Slide 2</div><div>Slide 3</div>
</div>
<p id="info"></p>
</body>
</html>
Open in editor

Browser Support

The following information will show you the current browser support for the HTML onscrollsnapchanging event attribute. Hover over a browser icon to see the version that first introduced support for this HTML event attribute.

This event attribute is supported in some modern browsers, but not all.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee