overscroll-behavior
Limited availability96% of users
A shorthand for setting how the browser handles reaching the boundary of a scroll area in both directions. It helps stop annoying 'scroll chaining'.
What's modern
From web-features, MDN's browser data and our snippets, checked dailyComingNot in Safari yet, so not every major browser supports it.
The old way and the modern waySee the snippet: Preventing scroll chaining without JavaScript →
Old way 10 lines
.modal-content {
overflow-y: auto;
}
/* JS: block the wheel only at the ends of the scroll */
modal.addEventListener('wheel', (e) => {
const atTop = modal.scrollTop <= 0 && e.deltaY < 0;
const atEnd = modal.scrollTop + modal.clientHeight >= modal.scrollHeight && e.deltaY > 0;
if (atTop || atEnd) e.preventDefault();
}, { passive: false });
/* also needed for touch: a touchmove listener */Modern 4 lines
.modal-content {
overflow-y: auto;
overscroll-behavior: contain;
}See how modern your own CSS is.Check your CSS →
Quick facts
- Initial value
auto- Inherited
- No
- Applies to
- non-replaced block and inline-block elements
- Animation type
- discrete
Quick example
.scroll-box {
/* Stops all scroll chaining in both horizontal and vertical directions */
overscroll-behavior: contain;
}Values
containnoneautoRelated snippet
Preventing scroll chaining without JavaScriptLayout →overscroll-behavior browser support
BaselineLimited availabilityThis feature is not Baseline because it does not work in some of the most widely-used browsers.Not ready for production without a fallback.
Usage96%of people can use this4% use a browser without it.
Browsers
144+
150+
18+Mobile
144+Android
150+Android