Layout, paint, raster and compositing
Definition and purpose
Rendering turns resolved styles into visible output. Layout computes geometry, paint describes drawing operations, rasterization produces pixels, and compositing assembles rendered surfaces. These are useful conceptual stages, not a required identical implementation in every engine.
Geometry change
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; font: 16px sans-serif; color: #172033; background: white; } #a { height: 80px; background: navy; } </style> </head> <body> <div id="a">A</div> <div id="b">B</div> </body></html>B starts after the 80px block.
Syntax and mental model
Changing height can move subsequent content and require layout; changing a background often leaves geometry unchanged but needs drawing updates. A transform changes visual geometry without normal-flow sizing and may be handled in compositing when suitable. Layer promotion, memory use and raster scheduling depend on engine decisions. Record a Performance trace for repeated changes, compare layout and paint entries, and do not interpret a property name as proof of acceleration.
Visual displacement
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; font: 16px sans-serif; color: #172033; background: white; } #a { height: 40px; transform: translateY(20px); background: navy; } </style> </head> <body> <div id="a">A</div> <div id="b">B</div> </body></html>A moves visually; B retains its normal-flow position.
Common mistakes
Do not add will-change to every element. Extra resources can increase memory costs, and transform or opacity is not a universal guarantee of compositor-only work.
Practice and next steps
After trying the examples, complete the linked coding exercise and review questions. Predict the result before running your code. Prerequisite: Style resolution and invalidation. Next lesson: Typed OM and Houdini.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Layout, paint, raster and compositing — knowledge check
Five questions on layout, paint, raster and compositing.
Which stage calculates flow geometry?
What does rasterization produce?
Can a transform move a box without moving its next flow sibling?
Does transform guarantee compositor-only execution?
How can performance cost be investigated?