SyntaxStudy
Sign Up
Tailwind CSS Text Alignment, Decoration, and Transform Utilities
Tailwind CSS Beginner 1 min read

Text Alignment, Decoration, and Transform Utilities

Text alignment utilities (text-left, text-center, text-right, text-justify, text-start, text-end) control horizontal alignment. The text-start and text-end variants are logical properties that respect the writing direction, making them better for internationalised interfaces. Responsive variants like md:text-left allow you to centre text on mobile and left-align it on wider screens where the surrounding layout gives enough visual context. Text decoration utilities provide underline, overline, line-through, and no-underline, with further control over decoration colour (decoration-blue-500), style (decoration-dotted, decoration-dashed, decoration-wavy), thickness (decoration-2, decoration-4), and offset (underline-offset-4). These granular controls enable accessible link styling with clear visual distinction beyond just colour. Text transform utilities uppercase, lowercase, capitalize, and normal-case transform the displayed text without changing the underlying HTML. Truncation utilities text-truncate (truncate), text-ellipsis (truncate with ellipsis), and line-clamp-* control overflow text. The line-clamp-2, line-clamp-3, and similar utilities (from the official typography plugin or built into Tailwind v3.3+) clamp multi-line text to a maximum number of lines, essential for card descriptions and feed previews.
Example
<!-- Text alignment responsive -->
<p class="text-center md:text-left text-gray-600">
  Centered on mobile, left-aligned on desktop
</p>

<!-- Decorations: underline with custom style -->
<a href="#"
   class="underline decoration-blue-500 decoration-2 underline-offset-4
          hover:decoration-wavy hover:decoration-blue-700 transition-all">
  Styled link underline
</a>

<!-- Strikethrough for old price -->
<div class="flex items-center gap-3">
  <span class="line-through text-gray-400 text-sm">$99</span>
  <span class="text-2xl font-bold text-green-600">$49</span>
  <span class="bg-red-100 text-red-600 text-xs font-semibold px-2 py-0.5 rounded">50% OFF</span>
</div>

<!-- Text transform for badges and labels -->
<span class="uppercase tracking-wider text-xs font-bold text-purple-700 bg-purple-100 px-2 py-1 rounded">
  New Feature
</span>

<!-- Line clamp for card previews (v3.3+ built-in) -->
<div class="max-w-sm bg-white rounded-xl shadow p-4">
  <h3 class="font-semibold text-lg mb-2 truncate">Very Long Article Title That Gets Cut Off</h3>
  <p class="text-gray-500 text-sm line-clamp-3">
    This is a longer description of the article that will be clamped to exactly three lines
    of visible text regardless of how much content is actually here. A "..." ellipsis
    appears at the end to indicate truncation to the user.
  </p>
</div>

<!-- Whitespace and word break control -->
<p class="whitespace-nowrap overflow-hidden text-ellipsis max-w-xs text-gray-700">
  This single line will not wrap and shows ellipsis instead
</p>