Performance: Why consistent typography matters
Consistent typography affects page rendering speed and visual stability by reducing layout shifts and repaint costs.
html { font-size: 16px; } body { font-family: 'Bootstrap Sans', sans-serif; font-weight: 400; font-size: 1rem; } h1, .btn { font-weight: 600; font-size: 1.5rem; } p { font-weight: 400; font-size: 1rem; }body { font-size: 1rem; } h1 { font-size: 2.5rem; font-weight: 700; } p { font-size: 1.2rem; font-weight: 400; } .btn { font-size: 1.5rem; font-weight: 600; }| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Inconsistent typography sizes | Multiple style recalculations | Multiple reflows triggered | High paint cost due to text resizing | [X] Bad |
| Consistent typography with Bootstrap variables | Minimal style recalculations | Single reflow on load | Low paint cost, stable text layout | [OK] Good |
.fs-1 to .fs-6 for font sizes, where .fs-1 is the largest..fs-1 sets a large, consistent font size for headings, unlike other classes which control alignment or layout..fs-1 for largest font size -> Option Bclass="fs-3 fw-bold text-primary" to a paragraph in Bootstrap?fs-3 sets medium-large font size, fw-bold makes text bold, text-primary colors text blue..fs-2 and all body text uses .fs-5 for consistent typography. How should you apply these classes efficiently?Pass the test and this pattern moves unknown