Performance: Box sizing
MEDIUM IMPACT
Box sizing affects how the browser calculates element sizes, impacting layout stability and rendering speed.
div {
width: 200px;
padding: 20px;
box-sizing: border-box;
}div {
width: 200px;
padding: 20px;
box-sizing: content-box;
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| content-box with padding | Normal DOM nodes | Multiple reflows if padding changes | Higher paint cost due to layout shifts | [X] Bad |
| border-box with padding | Normal DOM nodes | Single reflow on size change | Lower paint cost, stable layout | [OK] Good |