Performance: Content area
The content area size affects layout calculations and paint times during page rendering.
Jump into concepts and practice - no test required
div {
width: 100vw;
height: 100vh;
padding: 50px;
box-sizing: border-box;
}div {
width: 100vw;
height: 100vh;
padding: 50px;
box-sizing: content-box;
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Content-box with padding and 100vw/100vh | 1 element | Multiple on resize | High due to overflow | [X] Bad |
| Border-box with padding and 100vw/100vh | 1 element | Single on resize | Lower paint cost | [OK] Good |
content area of a webpage usually contain?max-width property limits how wide the content area can grow.max-height limits height, min-width sets minimum width, and padding adds space inside the box.div.content {
width: 50rem;
max-width: 90%;
padding: 2rem;
margin: 0 auto;
}.content {
width: 600px;
margin: 0 0 auto;
}0 auto centers horizontally. Incorrect margins like auto 0 or 0 0 auto do not.max-width: 700px and padding: 1.5rem. Fixed width or wrong margins fail.0 2px 5px rgba(0,0,0,0.1) (small offset, blur, low opacity). Large offsets, no blur, or opacity 0.5 are less subtle.