CKTIS / CSS
text-align-last — last-line alignment
The text-align-last property controls alignment of a block’s last line and lines immediately before forced breaks. It lets those lines use a different alignment from the remaining lines.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
text-align-last: auto | start | end | left | right | center | justify | match-parent;text-align-last applies to block containers and is inherited. It affects the final line and every line immediately before a forced break, such as one introduced by a br element, not an ordinary soft wrap. It aligns line contents, not the block itself.
The initial value auto follows normal text alignment (text-align-all in the specification model), except that justify becomes start. start and end mean the logical beginning and end of the line; for horizontal text they depend on direction. left and right align to the line-left and line-right edges, respectively. These are the left and right edges in horizontal writing and the top and bottom edges in vertical-rl, vertical-lr, and sideways-rl. In sideways-lr, the order is reversed: line-left is the bottom edge and line-right is the top edge. center centers, and justify justifies. match-parent takes the parent’s value, resolving its start or end using the parent’s direction.
In the current specification draft, text-align is a shorthand that can reset text-align-last; put the more specific declaration after it. The specification description does not confirm support for every value in the target browser.
In the example, both Alpha before the forced break and the final line Beta should be right-aligned. Changing text-align-last to auto should make both left-aligned.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>text-align-last</title>
<style>
p {
width: 240px;
margin: 16px;
border: 1px solid;
font: 16px/24px monospace;
direction: ltr;
text-align: left;
text-align-last: right;
}
</style>
<p>Alpha<br>Beta</p>
</html>Result
Alpha and Beta appear on separate lines, both aligned to the right inside the bordered paragraph.
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.