Educational guide to text-align-last
Choose how each text block ends
Align the final line and lines before a forced break. Compare auto with explicit values and keep a consistent reading direction.
Mental model
text-align-last determines the alignment of a block’s last line and the line before a forced break, such as br. Other lines follow text-align. It does not select the last word or position the box in the layout.
- Soft wrap
A line fills up and the text continues on the next because space runs out. That break does not turn the preceding line into a last line.
- Forced break
A br ends the line even if space remains. That line receives text-align-last and the remaining text continues inside the same block.
- End of the block
The line where the paragraph ends also receives the property. If the whole paragraph fits on one line, that single line is the last.
auto and paragraph alignment
auto does not always mean start. It follows text-align, except with justify, where it uses start. An explicit value such as center or end can change the last line even when the rest of the paragraph uses another alignment.
One paragraph, four ways to finish
text-align: center · text-align-last: auto
The available width determines where the lines of this paragraph wrap. The general alignment stays in place until the end of the block. Compare how the reading ends with an automatic, centered, or justified value. A short ending.
text-align: justify · text-align-last: auto
The available width determines where the lines of this paragraph wrap. The general alignment stays in place until the end of the block. Compare how the reading ends with an automatic, centered, or justified value. A short ending.
text-align: justify · text-align-last: center
The available width determines where the lines of this paragraph wrap. The general alignment stays in place until the end of the block. Compare how the reading ends with an automatic, centered, or justified value. A short ending.
text-align: justify · text-align-last: justify
The available width determines where the lines of this paragraph wrap. The general alignment stays in place until the end of the block. Compare how the reading ends with an automatic, centered, or justified value. A short ending.
You can use the property without justifying the paragraph. The playground keeps text-align: justify to make comparison easier, not because it is required. Justifying a short last line can create excessive gaps; keep auto or start for prose when a different ending is not needed. hyphens: auto uses the declared language and an available dictionary, without guaranteeing hyphens.
Soft wrapping and forced breaks
A br creates another affected ending inside the same paragraph. Wrapping to fit the available width does not. With preserved white space, a newline in the content can also be forced; in normal HTML, a newline in the source usually collapses to a space.
The same text with an added br
Soft wrapping only · text-align-last: end
The browser wraps this paragraph to the available width. Some breaks appear when the window changes, but this stretch of text ends here. A short ending.
A br before the ending · text-align-last: end
The browser wraps this paragraph to the available width. Some breaks appear when the window changes, but this stretch of text ends here.
A short ending.
Use br when the break belongs to the content, such as a verse or postal address. Do not add it to preserve a composition that only works at one width. The property inherits: on a container, it can affect the last line of every descendant paragraph, rather than just the last paragraph. Limit the selector to the block you want to treat.
Start and end follow direction
start and end follow the block’s direction. In horizontal LTR writing, start is left and end is right; in RTL they swap. left and right keep their physical sides. Language through lang and direction through dir are different data.
A single line has an ending too
dir="ltr" · text-align-last: start
Read to the end
dir="ltr" · text-align-last: end
Read to the end
dir="rtl" · text-align-last: start
مرحبا بالعالم
dir="rtl" · text-align-last: end
مرحبا بالعالم
Alignment does not reverse reading order or center the block inside its parent. To choose general alignment, understand inline content and boxes, or compare justification methods, continue with the text-align guide linked below.
Common pitfalls
auto does not put the last line on the left
- Expected result
- The ending follows the declared alignment and direction.
- Cause
- auto follows text-align, with the exception of justify; start also depends on dir and does not always mean left.
- Solution
- Check both properties and dir. Use start to follow reading direction, or a physical side only when that is the intent.
An intermediate line changes too
- Expected result
- Only block endings or lines before a forced break change.
- Cause
- There is a br or a preserved newline; the property is not limited to the paragraph’s final visible line.
- Solution
- Check the HTML and white-space. Remove breaks added just to match a screenshot and allow natural reflow.
The ending is spaced too widely
- Expected result
- Words keep a readable rhythm at several widths.
- Cause
- text-align-last: justify distributes a short line’s space across only a few justification opportunities.
- Solution
- Return to auto or start and check enlarged text. Do not insert extra spaces to simulate alignment or force justification as a guarantee of readability.
Support and compatibility
text-align-last is Baseline Widely Available since September 2022. The playground’s seven values have established support. Compatibility is independent of text-justify and does not imply support for every part of the current drafts’ syntax.
In an older browser that ignores the declaration, the paragraph keeps normal text-align alignment without this adjustment to endings. The scenes use native CSS, need no JavaScript, and allow text to grow and wrap. Check the actual fonts, language, hyphenation, and width before reusing a justified composition.