Tailwind CSS Text-align
Align text in Tailwind CSS with text-left, text-center, text-right, and text-justify utilities. Includes responsive alignment and real-world examples.
Interactive Text Align Playground
Try each class live and inspect the CSS output.
Preview text
text-lefttext-align: left;The text-align utility class in Tailwind CSS allows you to control the horizontal alignment of text within an element. You can center text, left-align, right-align, or justify it โ all without writing custom CSS.
How to apply Tailwind Text Align
To apply the text alignment to an element, you can use the text-{alignment} utility class, where {alignment} represents the desired alignment. Here are the available alignment options:
text-left:Aligns the text to the left.text-center:Centers the text horizontally.text-right:Aligns the text to the right.text-justify:Justifies the text, spreading it evenly across the container.
Tailwind Text-center
1<div class="text-center">2 In a bustling city, cars whizzed by, their honks echoing through the streets.3 Pedestrians hurriedly walked, lost in their own thoughts, while street vendors4 enticed passersby with the aroma of freshly brewed coffee and sizzling5 delicacies. Neon lights illuminated the night sky, painting the cityscape in a6 kaleidoscope of colors.7</div>
In a bustling city, cars whizzed by, their honks echoing through the streets. Pedestrians hurriedly walked, lost in their own thoughts, while street vendors enticed passersby with the aroma of freshly brewed coffee and sizzling delicacies. Neon lights illuminated the night sky, painting the cityscape in a kaleidoscope of colors.
Tailwind Text-right
1<div class="text-right">2 In a bustling city, cars whizzed by, their honks echoing through the streets.3 Pedestrians hurriedly walked, lost in their own thoughts, while street vendors4 enticed passersby with the aroma of freshly brewed coffee and sizzling5 delicacies. Neon lights illuminated the night sky, painting the cityscape in a6 kaleidoscope of colors.7</div>
In a bustling city, cars whizzed by, their honks echoing through the streets. Pedestrians hurriedly walked, lost in their own thoughts, while street vendors enticed passersby with the aroma of freshly brewed coffee and sizzling delicacies. Neon lights illuminated the night sky, painting the cityscape in a kaleidoscope of colors.
Tailwind Text-left
1<div class="text-left">2 In a bustling city, cars whizzed by, their honks echoing through the streets.3 Pedestrians hurriedly walked, lost in their own thoughts, while street vendors4 enticed passersby with the aroma of freshly brewed coffee and sizzling5 delicacies. Neon lights illuminated the night sky, painting the cityscape in a6 kaleidoscope of colors.7</div>
In a bustling city, cars whizzed by, their honks echoing through the streets. Pedestrians hurriedly walked, lost in their own thoughts, while street vendors enticed passersby with the aroma of freshly brewed coffee and sizzling delicacies. Neon lights illuminated the night sky, painting the cityscape in a kaleidoscope of colors.
Tailwind Text-justify
1<div class="text-justify">2 In a bustling city, cars whizzed by, their honks echoing through the streets.3 Pedestrians hurriedly walked, lost in their own thoughts, while street vendors4 enticed passersby with the aroma of freshly brewed coffee and sizzling5 delicacies. Neon lights illuminated the night sky, painting the cityscape in a6 kaleidoscope of colors.7</div>
In a bustling city, cars whizzed by, their honks echoing through the streets. Pedestrians hurriedly walked, lost in their own thoughts, while street vendors enticed passersby with the aroma of freshly brewed coffee and sizzling delicacies. Neon lights illuminated the night sky, painting the cityscape in a kaleidoscope of colors.
Responsive Tailwind Text Align
Tailwind CSS allows you to apply text alignment classes responsively at different breakpoints. To use responsive text alignment classes, you can append the breakpoint prefix to the utility class. For example, md:text-right aligns the text to the right starting from the medium breakpoint and above.
1<div class="text-left md:text-right">2 <!-- Text content here -->3</div>
This text starts left, centers on medium screens, right-aligns on large screens.
In the above example, the text is aligned to the left by default (text-left), but starting from the medium breakpoint and above, the text alignment is changed to the center (md:text-center) and on large screen, the text alignment is changed to right(lg:text-right).
Interaction States (Hover/Focus)
While not commonly used, you can change alignment on interaction:
1<p class="text-left hover:text-center transition-all duration-300">2 Hover to center this text.3</p>
Hover to center this text.
โ ๏ธ Be cautious with alignment shifts on interaction โ it can disrupt flow and layout.
Arbitrary Value Usage
text-align doesn't support arbitrary values (like text-[something]) because CSS text-align only accepts certain keywords. If you need something very custom, you'll need inline styles or custom classes.
1<p style="text-align: center">Custom center aligned</p>
Custom center aligned
Customization in tailwind.config.js
Tailwind doesnโt allow extending text-align classes directly since it's a limited CSS property โ but you can create custom utilities using the addUtilities plugin.
1// tailwind.config.js2plugin(function ({ addUtilities }) {3 addUtilities({4 ".text-balance": {5 textAlignLast: "center",6 },7 });8});
Then use:
1<p class="text-balance">Text with balanced alignment</p>
Real UI Examples (Practical + Creative)
๐ฌ Chat Bubbles (LTR/RTL support)
1<div class="space-y-2">2 <!-- User Message -->3 <div class="text-right">4 <div class="inline-block bg-blue-100 text-blue-900 px-4 py-2 rounded-lg">5 Hey, are we still on for today?6 </div>7 </div>89 <!-- Response -->10 <div class="text-left">11 <div class="inline-block bg-gray-200 text-gray-800 px-4 py-2 rounded-lg">12 Yes, see you at 5!13 </div>14 </div>15</div>
Hey, are we still on for today?
Yes, see you at 5!
๐ Article Summary Section
1<section class="max-w-2xl mx-auto text-justify">2 <h2 class="text-xl font-semibold mb-2 text-center">Overview</h2>3 <p>4 This article explores the practical uses of Tailwind CSS for layout,5 spacing, and component structure. Youโll learn how utility-first styling6 speeds up frontend development and keeps your styles consistent.7 </p>8</section>
Overview
This article explores the practical uses of Tailwind CSS for layout, spacing, and component structure. Youโll learn how utility-first styling speeds up frontend development and keeps your styles consistent.
๐งพ Invoice Summary Footer
1<div class="text-right text-sm mt-4">2 <p>Subtotal: $250.00</p>3 <p>Tax: $20.00</p>4 <p class="font-bold">Total: $270.00</p>5</div>
Subtotal: $250.00
Tax: $20.00
Total: $270.00
Best Practices
-
Use
text-centersparingly โ it's great for short content like headings, not long paragraphs. -
Prefer
text-start/text-endfor RTL-compatible designs. -
Donโt mix
text-alignwithflexorgridalignment unless you know whatโs doing the positioning. -
Use
text-justifyonly when necessary โ it can cause awkward spacing on small screens.
Accessibility Notes
-
Text alignment doesn't directly affect screen readers, but it can impact readability:
-
Left-aligned text is the most readable in most languages.
-
Center-aligned text can be harder for dyslexic users or on small screens.
-
Justified text can introduce inconsistent word spacing, hurting readability.
๐ก If you're designing for accessibility, stick with text-left (or text-start) unless there's a solid design reason to do otherwise.
Tailwind Text Align Class Table
| Class | Properties |
|---|---|
| text-left | text-align: left; |
| text-center | text-align: center; |
| text-right | text-align: right; |
| text-justify | text-align: justify; |
โจ What's Next?
Windframe Tailwind blocks
Windframe is an AI visual editor for rapidly building stunning web UIs & websites
Start building stunning web UIs & websites!

