Challenge 2: Classify Shifts as Expected or Unexpected — Possible Solution ==================================================================== (a) A cookie-consent banner appearing at the top of the page 3 seconds after load -> COUNTS TOWARD CLS (unexpected shift) Nothing the user did caused this banner to appear — it shows up on its own timer, 3 seconds after load, with no click, tap, or keypress triggering it. Because it's injected ABOVE the existing page content (at the top), it pushes everything below it down, exactly matching the chapter's fourth common cause: "dynamically injected content above existing content." The user was likely already reading or about to interact with the content that just got shoved downward, making this a genuinely disruptive, unexpected shift by every definition the chapter gives. (b) An FAQ answer expanding below a question the user just clicked -> DOES NOT COUNT TOWARD CLS (user-initiated shift) This shift is a DIRECT, immediate consequence of the user's own action — they clicked specifically to expand this content, so its appearance and the resulting layout change are expected and intentional from the user's own perspective. This matches the chapter's explicit carve-out: "a shift caused directly by user interaction, like an accordion expanding on click, isn't 'unexpected' and isn't counted against CLS." The user asked for this to happen, so its visual consequences aren't treated as a layout-stability defect. WHY THIS WORKS AS AN ANALYSIS -------------------------------- The deciding question in both cases is the same: "did the user directly cause this specific change, close enough in time and clearly enough tied to their action that they'd expect it?" Case (a) fails this test entirely — the banner's timing has nothing to do with anything the user did. Case (b) passes cleanly — the user's click is the direct, immediate cause of the exact content that then appears. This is exactly the distinction that separates a genuine CLS problem (content moving around the user did not ask for) from ordinary, expected interactive UI behavior (content moving because the user asked it to).