text-align-last
Controls alignment of the last line of text. Lets you justify all lines except the final one.
Quick example
p { text-align: justify; text-align-last: center; } Syntax
auto | start | end | left | right | center | justifyQuick facts
Initial value
autoInherited
Yes
Examples
Center the last line of a justified paragraph
p {
text-align: justify;
text-align-last: center;
}
/* All lines justified except the last, which is centered */ Use text-align-last to fix the look of justified paragraphs with short final lines.
Right-align captions
.caption {
text-align-last: right;
}
/* Last (and only) line of caption aligns right */ Single-line captions or labels can use text-align-last for right alignment.
text-align-last Browser Support
Widely available Since 2016 85% global usage
This feature is well established and works across many devices and browser versions. It has been available across browsers since 2016.
Safe to use without fallbacks.
Common pitfalls
Only affects the last line
text-align-last only applies to the final line of a block. Single-line elements behave differently than multi-line.
Interacts with text-align
text-align-last overrides text-align for the last line only. If you set text-align: center and text-align-last: right, all lines are centered except the last.