Dev.Lib
arrow_backBack to Blogs
LEVEL_033.5June 27, 20261 min read

CSS containment

Browser Performance

`contain: layout style paint` isolates subtree recalc — useful for list items, widgets, virtualized rows.

Summary

contain: layout style paint isolates subtree recalc — useful for list items, widgets, virtualized rows. content-visibility: auto skips rendering off-screen content (approximate size required). Wrong containment breaks position: fixed descendants or overflow-visible popovers. Measure before/after on large lists.

Code example

.list-item {
  contain: layout style paint;
  content-visibility: auto;
  contain-intrinsic-size: 0 80px;
}

Key points

  • contain: layout style paint isolates subtree recalc — useful for list items, widgets, virtualized rows.
  • content-visibility: auto skips rendering off-screen content (approximate size required).
  • Wrong containment breaks position: fixed descendants or overflow-visible popovers.
  • Measure before/after on large lists.

Further reading

Related concepts