scrollIntoView: Programmatic Scrolling

Make a real scrollIntoView call on the teacher’s exercise sheet: block and inline, which containers scroll along, a sticky title and scroll-padding, and…

Why it matters

"Jump to section", the latest chat message, the form field with an error, a highlighted search hit: they all need scrolling to an element. Without scrollIntoView you work out offsetTop and scrollTop yourself in every container, and it is easy to get wrong.

The key idea

scrollIntoView scrolls every container, up to the window

Common mistakes

Try it in this playground