PSA: AI agents love slapping broad :has() rules on CSS, causing huge style recalcs

jh3yy · x · 2026-11-07

jh3yy warns to keep CSS :has() rules tight — no wildcards or broad targets. Agents love putting :has() on landmark elements, which can trigger massive style recalcs from seemingly unrelated rules.

The accompanying demo shows Chrome's invalidation walk: one .active class change re-checks every :has() anchor up the tree, and a shared list containing restyles everything inside main — 29 of 30 elements restyled for one change, while Firefox/Safari only restyle the .tab subtree.

Related event: Developers warn AI agents overuse CSS :has(), risking full-page recalculation(3 posts)→

Original post →

More from coding & agent

coding & agent channel →