Performance: Why typography control is needed
Typography control affects page readability and visual stability, impacting user experience and layout shifts.
Jump into concepts and practice - no test required
<p class="text-base">Hello</p> <p class="text-lg font-bold">World</p> <p class="text-lg">!</p>
<p class="text-base">Hello</p> <p class="text-lg font-bold">World</p> <p style="font-size: 24px;">!</p>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Inconsistent font sizes with inline styles | Multiple style recalculations | Multiple reflows triggered | High paint cost due to layout shifts | [X] Bad |
| Consistent Tailwind typography classes | Single style calculation | Single reflow | Low paint cost with stable layout | [OK] Good |
text- control font size, e.g., text-lg.font-bold controls weight, bg-blue-500 controls background color, p-4 controls padding.class="text-sm font-semibold text-gray-700" to a paragraph?text-sm means small text size, font-semibold means semi-bold weight, text-gray-700 means dark gray color.<p class="font-bold letter-spacing-2">Hello</p> doesn't work. What is the error?tracking- prefix for letter spacing, e.g., tracking-wide, not letter-spacing-2.letter-spacing-2 is not a valid Tailwind class, so it won't apply spacing.text-xl means large text, font-bold means bold weight, text-blue-600 means blue color.leading-loose adds extra line spacing, matching the requirement.