Text Align Last
A practical review of CSS last-line alignment: what it changes in the layout, when it is a good fit, and how copy, search and assistive tools treat the result.
Is last-line alignment suitable for the job?
CSS last-line alignment is a good fit when the goal is visual control of the final line of a paragraph, heading or caption, and the words themselves must stay exactly as authored. The main benefit is that the layout engine can left-align, right-align, center or justify that last line while search, editing, translation and data export still see the original character sequence.
The decisive tradeoff is that the effect belongs to the stylesheet. It travels only with a destination that still applies CSS (or an equivalent rich-text style). Plain text is preferable for source that must look the same in mail, chat, logs, spreadsheets, legal dumps, version control and any other channel that keeps characters and drops presentation. If the last line’s flush is meant to carry meaning, such as marking a title, put that meaning in structure (a heading, a label, a field) and treat alignment as decoration.
What the transformation actually changes
text-align-last is CSS presentation. It tells the formatter how to place the last line box of a block, and, under the CSS Text rules, the line immediately before a forced line break. Stored characters stay in author order. Combining marks stay attached to their base letters. Multi-code-point emoji stay as the same sequences. Nothing in this property reverses words, mirrors glyphs, substitutes lookalike Unicode, or changes the bidirectional reading order.
Typical values and what they do to that last line:
- auto: follow the block’s text-align value.
- start and end: align to the start or end edge of the line, using writing mode and direction.
- left, right, and center: physical alignment of the last line box.
- justify: justify the last line as well as the lines above it.
text-align still governs the earlier lines. A common pattern is a justified block whose last line stays ragged under the default auto behavior, or a block that also justifies or centers that final line. start and end follow the writing mode, so a right-to-left block already treats start as the right edge. The property does not insert right-to-left overrides or mirrored letters; direction remains whatever dir, lang and Unicode bidi already set.
p {
text-align: justify;
text-align-last: center;
}
Online “align text” gadgets sometimes pad with ordinary spaces, figure spaces or fullwidth spaces so a last line looks centered in a monospaced box. That is a stored-character change: wrapping, copy and search all see the extra marks. Character reversal, mirrored-letter fonts and Unicode styling are a third family: they rewrite or replace code points, so the string itself is different. Last-line alignment via CSS leaves the string alone and only moves the line box.
Copy, sharing, reading order and assistive use
Because the characters are unchanged, find-in-page, spellcheck, search indexes and most translation pipelines match the original words. Copy into a plain-text field yields those same words with the alignment gone. The pasted prose remains readable; it simply no longer shows a centered or justified last line. Rich-text paste is destination-specific: some editors keep a generic text-align, some keep last-line alignment, some keep neither. This review has no scoped paste test of named mail clients, chat apps or CMS fields, so treat survival of the look as unverified until checked in the actual target.
Assistive technology generally follows DOM or source order, which is the same order as the stored text. Last-line centering or justification does not create a new spoken sequence. That is why a plain-text equivalent is simply the same sentence without the style. If a workflow needs the visual flush to survive in a context with no CSS, the alternative is a different transformation (fixed-width padding or a generated image), and that alternative needs its own check for wrapping, copy and screen-reader output. Do not assume one successful rendering in a browser means every reader, engine or pasteboard will show the same last line.
Compatibility and layout quality still matter even though meaning is preserved. User agents that ignore text-align-last fall back to text-align alone. Justifying a short last line can open large word gaps. Mixed scripts, extra letter-spacing and very short leftover lines vary by engine. Those are presentation risks in the styled document; they do not rewrite the string. For intended use that is a designed page or print stylesheet, last-line alignment is suitable. For intended use that is interchangeable plain text, skip the property and keep the unstyled source.