#1105: ScrollIntoViewOptions container attribute
Discussions
Log in to see TAG-private discussions.
Discussed
Jun 9, 2025 (See Github)
Jeffrey: DanC drafted a comment; we can post.
Discussed
Jun 23, 2025 (See Github)
Jeffrey: Suggest satisfied
with a comment that it'd be really nice if the specification included a description of the use case and some example code.
Jeffrey: The explainer and spec has no intro section. Will suggest satisfied but with that request.
Discussed
Jun 30, 2025 (See Github)
Jeffrey: I wrote a draft comment for this (proposing satisfied; asking for some intro text for the spec).
Call approves; Jeffrey posts comment
Comment by @jyasskin Jul 2, 2025 (See Github)
Thank you for the explanation. We're happy with this extension, but we note that there's no long-lived explainer document, and the specification doesn't include any introductory text about use cases or example use. Could you work on adding that to the specification? Thanks!
Comment by @kurtextrem Sep 23, 2025 (See Github)
Hi, I really love this new option, as scrollIntoView's scroll hijacking behavior has bitten me in the past too (so I also think this solves a real big problem of the web platform). I have one request though:
Detection of the feature can be done in Javascript by doing a test scrollIntoView, and if done in a position: fixed descendant should prevent highjacking the user's scroll.
Could you please add an example for that? I assume you're thinking something like <div style="position:fixed;top:1px"><div id="scrollToThis">
, then calling window.scrollToThis.scrollIntoView({ container: 'nearest' })
on page load. If window.scrollY === 0
it is supported, otherwise it isn't?
Asking, because having a copy & paste-able example would make it easier for both humans and AI agents to adopt this :)
Comment by @flackr Sep 23, 2025 (See Github)
I added an example on the blink intent thread: https://groups.google.com/a/chromium.org/g/blink-dev/c/bfnPvqLfVi4/m/gtUoYhUpAgAJ
OpenedMay 30, 2025
こんにちは TAG-さん!
I'm requesting a TAG review of the ScrollIntoViewOptions container attribute.
There are many advantages of using scrollIntoView, it is an ergonomically simple way for a developer to request that a particular element is made visible, aligning it within the scroll padding of the scroller and snapping as appropriate.
However, in many circumstances it can be counter-intuitive that a scroll into view call scrolls all ancestor scrollers. E.g. If a slideshow or carousel uses a scrolling box for slides and uses scrollIntoView to advance to the next slide, this will also force the top level scroller to scroll the slideshow into view.
The container attribute on the ScrollIntoViewOptions dictionary allows a developer to use scrollIntoView without forcibly scrolling all of the ancestor scrolling containers.
This demo uses the API to show how it helps in practice.
Further details: