Performance: Absolute units
Absolute units affect page rendering speed by fixing element sizes, which can cause layout shifts on different screen sizes and resolutions.
Jump into concepts and practice - no test required
body { font-size: 1rem; }body { font-size: 16px; }| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Using px for sizes | Minimal | Can trigger reflows on zoom or device change | Moderate | [X] Bad |
| Using rem/em for sizes | Minimal | Fewer reflows due to flexible sizing | Lower | [OK] Good |
cm is an absolute unit, while em, rem, and % are relative units.width: 5 cm; is correct. Equal sign is invalid.div { width: 2in; }in unit meaningin stands for inches, an absolute unit representing physical inches on screen or print.in means inches, so width is in inches [OK]in is relative unitp { font-size: 12 pt; }12 pt is invalid.font-size: 12pt; with no space.pt is invalid unit3cm for width and 1in for height.box { width: 3cm; height: 1in; } is correct and uses absolute units as required.