Performance: Line height
Line height affects text layout and vertical spacing, impacting layout stability and paint performance.
Jump into concepts and practice - no test required
p { line-height: 1.5; }p { line-height: normal; }| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Using 'normal' line-height | Minimal | Multiple on font load and resize | Medium | [X] Bad |
| Using fixed numeric line-height (e.g., 1.5) | Minimal | Single initial reflow | Low | [OK] Good |
line-height control in a webpage?line-height property sets the amount of vertical space between lines of text in a block.line-height: 1.5;. Options B and C use incorrect assignment or units, D uses camelCase which is invalid in CSS.p { font-size: 16px; line-height: 2; }p { line-height: 20; }line-height: 20px;. Without units, 20 means 20 times font size, which is huge and may cause unexpected layout.rem units for font size scales text with root font size, good for responsiveness.line-height: 1.5; as a number scales line height relative to font size, adapting well on different devices.