freecoding.school100% FREE · NO SIGNUP
Neon DistrictISSUE #37 of 50

contain · layout · paint · style isolation

PrismaVSJank the Janitor
Prisma sayscontain isolates an element’s layout/paint so changes inside don’t reflow the whole page.

contain: layout paint promises the browser an element's internals won't affect outside layout, letting it skip recalculating the rest of the page when that subtree changes. On big, component-heavy pages this is a real performance win. content is a handy shorthand value.

Power-ups you unlock

Jank the Janitor attacks — common mistakes

Boss battleAdd contain:content to a self-contained widget; reason about the reflow it prevents.

Example code

<!doctype html><html><head><meta charset="utf-8">
<style>.widget{contain:content;background:#140a28;color:#e6e0ff;padding:14px}</style></head><body style="background:#06040d;padding:20px"><div class="widget">an isolated, self-contained widget</div></body></html>
▶ Open the interactive comic issue
‹ Will-Change · The Perf HintContent-Visibility · Render Skip ›