Performance: Block vs inline vs inline-block
MEDIUM IMPACT
This concept affects how elements are sized and laid out, impacting layout calculations and paint performance.
div { display: inline-block; width: 200px; height: 100px; }div { display: inline; width: 200px; height: 100px; }| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Block element for large containers | Moderate (creates block boxes) | 1 per container | Moderate | [OK] Good |
| Inline element with width/height set | Low | Multiple reflows when styles change | Low | [X] Bad |
| Inline-block for sized inline elements | Moderate | Single reflow | Low | [OK] Good |