π What Is text-align-last?
The text-align-last property controls thealignment of the last line of a paragraph or block whentext-align affects the rest of the lines. It is especially useful for text that is justified or multi-line formatted.
Note
β Affects only the last line
β Useful for typography, magazine layouts, and article formatting
π¦ Syntax
text-align-last syntax
text-align-last: auto | left | right | center | justify | start | end;π Values Explained
| Value | Description |
|---|---|
| auto | Default; follows the text-align value. |
| left | Align last line to the left. |
| right | Align last line to the right. |
| center | Center the last line. |
| justify | Force the last line to stretch fully across the width. |
| start | Align according to writing direction (LTR β left). |
| end | Align opposite to writing direction. |
π 1. Basic Example
Simple usage
p {
text-align: justify;
text-align-last: center;
}The paragraphβs main lines are justified, but the last line is centered.
π 2. Align Last Line to the Right
Right-align last line
p {
text-align: justify;
text-align-last: right;
}Perfect for signatures, quotes, authorship text, etc.
π 3. Force Justified Last Line
Full justify last line
p {
text-align: justify;
text-align-last: justify;
}The last line expands to take up full width β magazine-style formatting.
π 4. Using text-align-last Without Justification
Works with other alignment
p {
text-align: left;
text-align-last: right;
}Even if the paragraph is left aligned, the last line becomes right-aligned.
π 5. RTL (Right-to-Left) Compatibility
RTL example
p {
direction: rtl;
text-align: justify;
text-align-last: start;
}start aligns to the right in RTL languages.
π 6. Styling Headings with a Special Last Line
Heading multi-line effect
h1 {
width: 300px;
text-align: center;
text-align-last: left;
}Creates visually interesting headline formatting.
π§ͺ Real-World Examples
1οΈβ£ Article Paragraph Formatting
Magazine style
article p {
text-align: justify;
text-align-last: left;
}2οΈβ£ Special Alignment for Quotes
Quote formatting
blockquote {
text-align: justify;
text-align-last: right;
}3οΈβ£ Align Author Name on Last Line
Author credit
.author {
text-align: justify;
text-align-last: end;
}β οΈ Common Mistakes
- β Assuming it only works with justified text (it works with all alignments)
- β Forgetting that it affects only the last line
- β Using it on single-line text (no effect)
Note
π₯ Summary
text-align-last provides fine control over how the final line of a text block is aligned. Itβs especially useful for article layouts, quotations, headings, and RTL typography.
Learn more βMDN Docs π