Your AI chat scrolls wrong. Fix it in 4 lines of CSS A tutorial published by developer Marko Denic shows that an AI chat box can follow a streaming answer without JavaScript scroll hacks by setting the container to `display: flex` with `flex-direction: column-reverse`, `overflow-y: auto` and `overscroll-behavior: contain`, then deleting the `scrollTop = scrollHeight` line. The `column-reverse` direction makes the bottom of the box the resting position, so new streamed text stays in view, while the browser's scroll anchoring holds the user's place when they scroll up; a single `.messages` wrapper keeps DOM order intact for screen readers and the Tab key. The technique relies on scroll anchoring, which the article says works in Chrome, Edge, Firefox and Safari 27, and requires one JavaScript line, `chat.scrollTop = 0`, to jump to the bottom when a new message is sent. Your AI chat scrolls wrong. Fix it in 4 lines of CSS AI Coding Faster, Shipping Slower? Explore the 2026 State of DevEx Report with industry leaders Sponsor this newsletter · reach 9,500+ active developers https://markodenic.tech/sponsorship/ You’ve streamed the answer word by word https://markodenic.tech/stream-ai-answers-word-by-word-in-15-lines/ , and it looks great until the answer gets longer than the chat box. Then one of two things happens. Either the text keeps streaming below the fold and the user has to keep scrolling down to read it, or you “fix” that with this: output.textContent += value; chat.scrollTop = chat.scrollHeight; Now the box follows the answer, but it also yanks the user back to the bottom every time a new word arrives, even while they’re scrolling up to reread something. So you add a check for “is the user near the bottom?”, tune a pixel threshold, and it still flickers. The browser can do all of this on its own. You just have to flip the box upside down. The fix