demo · v138

Anchor pagination

A horizontal scroll gallery driven by plain <a href="#x"> tags. scroll-target-group: auto on the link container promotes every anchor to a scroll marker. The browser tracks which target is current and the matching link gets :target-current automatically — no IntersectionObserver, no scroll listener, no JS.

Unflagged in Chrome 138. scroll-target-group: auto on a container makes its descendant <a> elements behave like ::scroll-marker pseudos — including the auto-tracked :target-current selector — without giving up real anchor semantics (focus, keyboard, accessible name).
probing scroll-target-group…
current target:
:target-current selector: auto-tracked by engine
JS listeners: 0

The CSS

nav.pager {
  scroll-target-group: auto;            /* every <a href="#x"> descendant becomes a scroll marker */
}
nav.pager a:target-current {            /* engine sets this on the marker pointing at the
                                           current-most snap point of the scroller */
  background: black;
  color: white;
}

What's happening

  1. Without scroll-target-group, anchors are just anchors — clicking scrolls to the target, but the browser doesn't track which target is "current" as the user scrolls.
  2. With scroll-target-group: auto, the container forms a scroll marker group. Each descendant anchor is paired with its target, and exactly one anchor matches :target-current at any moment.
  3. The pairing rule is the same as ::scroll-marker: the marker for whichever target is most visible in the nearest scroller.
  4. Unlike ::scroll-marker, real <a> elements keep their accessible name, focusability, and keyboard semantics. AT users can tab through them and they hear "Overview, link" — not a CSS pseudo.
  5. This was the missing primitive for any pattern where you need both navigation and visible "you are here" state — pagination, breadcrumbs, vertical ToC.

see also