The text-align-last property lets you align the final line of a text block differently from the rest of the paragraph — especially useful with justified text.
01
Last line
Final row only.
02
auto
Default mode.
03
justify pair
Fix ragged end.
04
left / right
Physical align.
05
center
Center finale.
06
text-align
Works with it.
Fundamentals
Introduction
The text-align-last property in CSS is used to set the alignment of the last line of a text block or the line right before a forced line break.
This property is particularly useful for adjusting the text alignment in justified text blocks or for creating specific text alignment effects at the end of paragraphs.
Definition and Usage
Apply text-align-last on the same block element where you set text-align. It only changes the final line; earlier lines keep the main alignment.
A common pattern is text-align: justify; with text-align-last: left; or right; so the paragraph looks even except for a cleaner closing line.
💡
Beginner Tip
When a paragraph has only one line, that line is both the first and last line, so text-align-last affects it too.
Foundation
📝 Syntax
The syntax for the text-align-last property is simple and follows the standard CSS property-value format:
syntax.css
element{text-align-last:value;}
Here, value can be one of several predefined values that determine the alignment of the last line.
Basic Example
justify-last.css
p{text-align:justify;text-align-last:right;}
Syntax Rules
Use it on block containers such as p, div, and table cells.
Pair it with text-align when you want different behavior on the final line.
auto makes the last line follow the element’s text-align value.
It also affects the line immediately before a forced break from <br>.
Related Properties
text-align — aligns all lines in the block
line-height — controls vertical spacing between lines
hyphens — can improve justified paragraph appearance
Defaults
🎯 Default Value
The default value of the text-align-last property is auto. This means the alignment of the last line follows the alignment of the text block as a whole.
Cheat Sheet
⚡ Quick Reference
Question
Answer
Default value
auto
Common values
left, right, center, justify
Best paired with
text-align: justify
Applies to
Block containers and table cells
Inherited
Yes
Animatable
No
Reference
💎 Property Values
Value
Example
Description
auto
text-align-last: auto;
The last line inherits the alignment value of the text-align property.
left
text-align-last: left;
The last line is aligned to the left.
right
text-align-last: right;
The last line is aligned to the right.
center
text-align-last: center;
The last line is centered.
justify
text-align-last: justify;
The last line is justified, stretched so the line fills the full width.
autoleftrightcenterjustify
Context
When to Use text-align-last
text-align-last is most helpful when the final line needs different treatment:
Justified articles — Prevent an awkward stretched last line by setting text-align-last: left.
Formal layouts — Right-align the closing line of a justified paragraph for a editorial look.
Poetry or quotes — Center only the final line while keeping earlier lines left-aligned.
Forced breaks — Control alignment on the line before a <br> tag.
Preview
👀 Live Preview
Both paragraphs use text-align: justify. The second adds text-align-last: right so the final line aligns differently:
text-align-last: auto
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor.
text-align-last: right
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus imperdiet, nulla et dictum interdum, nisi lorem egestas odio, vitae scelerisque enim ligula venenatis dolor.
Hands-On
Examples Gallery
Start with the reference justify + right-last-line example, then try left-last for cleaner justified text, centered closings, and a quote layout.
📜 Last Line Alignment
Align the last line of a paragraph differently from the rest — matching the reference example.
Example 1 — Justified text with a right-aligned last line
In this example, we’ll align the last line of a paragraph to the right while the rest of the paragraph is justified.
index.html
<style>p{text-align:justify;text-align-last:right;}</style><p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
</p>
The quote body is justified while the author attribution on the last line aligns to the right.
How It Works
Put the author name in the same paragraph as the quote text so it becomes the last line and picks up text-align-last: right.
Companion
text-align-last in the family
text-align-last fine-tunes the final line after you set the main alignment with text-align. Use both together when you want justified paragraphs without an awkward closing line.
justify-pair.css
p{text-align:justify;text-align-last:left;}
🧠 How text-align-last Works
1
text-align sets all lines
The block’s main alignment applies to every line, including left, center, right, or justify.
Base rule
2
text-align-last targets the finale
A separate keyword overrides alignment for the last line or the line before a forced break.
Override
3
auto follows text-align
With auto, the last line uses the same alignment as the rest of the block.
Default
=
📄
Polished paragraph endings
Justified and multi-line blocks look cleaner with controlled last-line alignment.
Compatibility
Browser Compatibility
The text-align-last property is supported in most modern browsers, including current versions of Chrome, Firefox, Safari, Edge, and Opera. It is always a good practice to test your website across different browsers to ensure compatibility.
✓ Modern browsers · Wide support
Reliable in current browsers
Chrome, Firefox, Edge, and Opera support text-align-last well. Safari added full support in recent versions.
94%Modern browser support
Google Chrome47+ · Desktop & Mobile
Full support
Mozilla Firefox49+ · Desktop & Mobile
Full support
Apple Safari16+ · macOS & iOS
Full support
Microsoft Edge79+ · Chromium
Full support
Opera34+ · Modern versions
Full support
Testing tip
Compare justified paragraphs with and without text-align-last in Safari and Chrome to confirm the last line behaves as expected.
text-align-last property94% supported
Bottom line:text-align-last is safe for modern projects, especially when paired with text-align: justify.
Wrap Up
Conclusion
The text-align-last property is a handy tool for web developers looking to fine-tune the alignment of text within a block.
By customizing the alignment of the last line of text, you can achieve a more polished and professional look for your web content. Experiment with different alignment values to see how this property can enhance the readability and aesthetics of your web pages.
Pair text-align-last with text-align: justify for cleaner paragraphs
Use left on the last line to fix stretched short closings
Test multi-line blocks in your target browsers
Keep author names or signatures on the last line when using right alignment
Remember that single-line paragraphs are affected too
❌ Don’t
Expect last-line control without setting text-align first
Use justify on very short paragraphs where last-line tweaks are unnecessary
Forget that forced <br> lines also count for this property
Hide important text in truncated last lines without an accessible alternative
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about text-align-last
Use these points when polishing paragraph alignment.
5
Core concepts
★01
auto Default
Follows text-align.
Default
⚙02
Last line
Final row only.
Scope
◉03
justify pair
Most common use.
Pattern
▦04
left / right
Clean endings.
Values
🔄05
text-align
Set both together.
Companion
❓ Frequently Asked Questions
text-align-last sets the horizontal alignment of the last line in a block of text, or the line immediately before a forced line break.
text-align controls all lines in a block. text-align-last overrides the alignment for only the final line.
The default value is auto, which means the last line follows the text-align value of the element.
Justified paragraphs often stretch the last line awkwardly. text-align-last lets you left-align, right-align, or center just that final line for a cleaner look.
It applies to block containers and table cells that contain text, such as p, div, and td elements.