Performance: Text alignment
Text alignment affects the browser's paint phase by changing how text is visually arranged but has minimal impact on layout or load speed.
Jump into concepts and practice - no test required
<div class="text-center"><p>Centered text</p></div><div style="text-align:center;"><p>Centered text</p></div>| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Inline style text-align | No extra DOM nodes | 0 reflows | Triggers paint on change | [!] OK |
| Tailwind text alignment class | No extra DOM nodes | 0 reflows | Triggers paint on change, cached styles | [OK] Good |
text-left, text-center, text-right, and text-justify to align text horizontally.text-center aligns text horizontally in the center of its container.text-left, text-center, text-right, and text-justify for horizontal text alignment.text-right. The option text-align-right is not a valid Tailwind class.<div class="text-justify">This is a sample paragraph.</div>
text-justify class effecttext-justify class makes text spread so both left and right edges align evenly, creating a block of text with straight edges on both sides.<p class="text-center sm:text-left">Hello World</p>
sm:, md: apply from that screen size and up.text-left for default (small screens) and md:text-center for medium and above to get the desired effect.md: applies from medium screens (tablets) and up, lg: applies from large screens (desktops) and up.text-left, md:text-center, and lg:text-right.