Overscroll and scroll anchoring
Definition and purpose
Scroll chaining occurs when input reaches a scroll boundary and propagates to an ancestor scroller. Scroll anchoring is different: it compensates for layout changes so the visible content can stay stable while content above changes.
Contain vertical chaining
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; font: 16px sans-serif; color: #172033; background: white; } #outer { height: 180px; width: 260px; overflow: auto; } #b { height: 100px; width: 200px; overflow: auto; } #outer > div:last-child { height: 300px; } #a, #t { height: 180px; } #b { overscroll-behavior-y: contain; } </style> </head> <body> <div id="outer" tabindex="0" aria-label="Outer scroll"> <div id="b" tabindex="0" aria-label="Inner scroll"> <div id="a">Updates</div> <div id="t">Reading content</div> </div> <div>More content</div> </div> </body></html>Vertical boundary input is contained; horizontal behavior is unchanged.
Syntax and mental model
overscroll-behavior-y: contain prevents vertical scroll chaining and nonlocal boundary actions, while none also suppresses local overscroll effects where implemented. It does not stop programmatic scrolling. overflow-anchor: none excludes a region and its descendants from anchor selection; setting it on the scroller disables anchoring there. Prefer reserving space for late-loading content to disabling anchoring globally. Suppression triggers, snap constraints and anchor selection mean not every layout change is compensated.
Exclude an unstable region
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; font: 16px sans-serif; color: #172033; background: white; } #outer { height: 180px; width: 260px; overflow: auto; } #b { height: 100px; width: 200px; overflow: auto; } #outer > div:last-child { height: 300px; } #a, #t { height: 180px; } #a { overflow-anchor: none; } </style> </head> <body> <div id="outer" tabindex="0" aria-label="Outer scroll"> <div id="b" tabindex="0" aria-label="Inner scroll"> <div id="a">Updates</div> <div id="t">Reading content</div> </div> <div>More content</div> </div> </body></html>The updates region cannot be chosen as anchor; the reading region remains eligible.
Common mistakes
Do not confuse overflow-anchor with anchor-name. Neither overscroll-behavior nor scroll anchoring replaces reserving image space. Use actual wheel or touch tests to verify chaining, not just scrollTop assignment.
Practice and next steps
After trying the examples, complete the linked coding exercise and review questions. Predict the result before running your code. Prerequisite: Scroll snap and scroll padding. Next lesson: Anchor positioning.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Overscroll and scroll anchoring — knowledge check
Five questions on overscroll and scroll anchoring.
What is scroll chaining?
What does scroll anchoring try to preserve?
Which declaration prevents vertical chaining?
How can an unstable region be excluded from anchor selection?
What reduces late image layout shifts at the source?