Paragraphs & wrapping

text-align-last

text-align-last sets how the last line of a paragraph is aligned. In a justified paragraph you can center the last line, or stretch it to the full width as well.

Syntax

auto | start | end | left | right | center | justify

Preview

The quick brown fox jumps over the lazy dog. 素早い茶色の狐がのろまな犬を飛び越える。
Presets
Drag the bottom-right corner to resize

Code

.box {
  text-align: justify;
  text-align-last: center;
}

Controls

text-align-lastcenter
text-align-last
The quick brown fox jumps over the lazy dog. 素早い茶色の狐がのろまな犬を飛び越える。

About

Values

  • auto: follows text-align, except that when text-align is justify the last line is aligned to the start. This is the initial value.
  • start, end, left, right, center and justify: align the line like the same value of text-align. With justify the last line is stretched to the full width too.

Besides the last line, it also applies to a line right before a forced break such as <br>. The preview on this page adds text-align: justify as a supporting declaration, so the other lines stay justified and only the last line changes.

The spec also has match-parent, which takes the parent's text-align, but only Safari supports it and the syntax view on this page does not include it, so it is left out.

Comments