Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Typography

The text-align-last property

Reference for the CSS text-align-last property: aligning or justifying the final line of a block, how it relates to text-align, with live examples.

The text-align-last property sets the alignment of the last line of a block, and of any line that comes right before a forced line break. By default the last line follows text-align, except that justify falls back to start for it. This property lets you choose something else, such as centering the last line of justified text, or justifying a single short line.

CSS
.quote {
  text-align: justify;
  text-align-last: center;
}

Try it

Last line of justified text
A one-line label spread across the box

A single line is also a "last line", so justify spreads the words across the full width.

Syntax

CSS
text-align-last: auto | start | end | left | right | center | justify;
  • Initial value: auto
  • Applies to: block containers
  • Inherited: yes
  • Animatable: no
  • Computed value: as specified

Values

Value Description
auto The last line uses text-align; when that is justify, it uses start.
start / end Aligns to the start or end edge of the line, following text direction.
left / right Aligns to the physical left or right.
center Centers the last line.
justify Stretches the last line to fill the width.

Usage notes

  • Single-line blocks count. A block with one line has only a last line, so text-align-last fully decides its alignment. Combined with text-align: justify it is a quick way to spread short labels.
  • Forced breaks. A line that ends with a <br> is also treated as a last line.
  • Justifying short lines looks odd. With few words, the gaps become very wide. Use it for headings and labels, not for sentences.
  • Order of properties. If both are set, text-align-last wins for the last line; text-align still applies to all other lines.
  • Typical use. Centered last lines for pull quotes, or end-aligned signatures in justified letters.

Browser support

Supported in current versions of all major browsers; older Safari releases lacked it, so check a compatibility table if you must support them.