Re: [csswg-drafts] [selectors] :last-in-column / :nth-last-in-column() pseudo-classes for wrapped flex and grid layouts (#13729)

@Loirooriol Thanks for flagging the layout circularity issue. I'm aware of the [FAQ position](https://wiki.csswg.org/faq/#selectors-that-depend-on-layout) on layout-dependent selectors — pseudo-classes like :last-in-column are a non-starter.

But hasn't this exact class of problem already been solved by Scroll State Container Queries? The pattern there — container holds post-layout state, only descendants query it, container's own layout properties are untouched — seems directly applicable here.

What if column-position were a layout-state container feature rather than a selector?


.masonry-item {
  container-type: layout-state;
}

.masonry-item > .card {
  @container layout-state(column-position: last) {
    /* styles descendants, not the container — no circularity */
  }
}
The UA already computes column assignment during flex/grid/multicol layout — this would just expose it through the existing @container mechanism, with the same circularity guarantees as scroll-state(stuck).

Is there a reason this approach wouldn't work here? Would love to hear if there are gotchas I'm missing with extending container queries to layout-position states.


-- 
GitHub Notification of comment by devi-prsd
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/13729#issuecomment-4132827433 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 26 March 2026 09:00:28 UTC