text-align-last

The property text-align-last specifies the alignment of the last line of text when the property text-align is set to justify.

Initial Value auto
Applies to Block container
Inheritance yes
Animation discrete

The property text-align-last describes how the last line of a block or line is justified just before a forced line break. If set to auto, the content in the corresponding line is aligned with text-align-all, unless text-align-all is set to justify, in which case it is aligned with the start of the block. All other values ​​are interpreted as described for text-align.

Important to note that if there is only one line in an element (for example, in a paragraph), then it is considered to be the first and last line at the same time, and its alignment will be as specified by text-align-last, not by text-align.

Syntax

/* Keyword values */

text-align-last: auto;
text-align-last: start;
text-align-last: end;
text-align-last: left;
text-align-last: right;
text-align-last: center;
text-align-last: justify;

/* Global values */

text-align-last: inherit;
text-align-last: initial;
text-align-last: unset;

Description

valuewhat it does
autoDefault value. The last line automatically fits the element’s width and is left-aligned.
leftThe last line is left aligned.
rightThe last line is right-aligned.
centerThe last line is center aligned.
justifyThe last line is justified just like the rest of the lines of text.
startThe last line is aligned to the initial edge of the block (left if the text direction is left to right, and right if the text direction is right to left).
endThe last line is aligned to the final edge of the block (right if the text direction is left-to-right, and left if the text direction is right-to-left).
inheritThe value is inherited from the parent element.
initialSets the default value.

Examples

Below are examples of various text-align-last values and their respective result.

left

Fusce sodales gravida eros, in vulputate nulla sollicitudin sit amet. Proin volutpat ut tellus a vulputate. Sed hendrerit sagittis ligula eget vulputate. Aliquam erat volutpat.

In sed vestibulum tellus.

right

Fusce sodales gravida eros, in vulputate nulla sollicitudin sit amet. Proin volutpat ut tellus a vulputate. Sed hendrerit sagittis ligula eget vulputate. Aliquam erat volutpat.

In sed vestibulum tellus.

center

Fusce sodales gravida eros, in vulputate nulla sollicitudin sit amet. Proin volutpat ut tellus a vulputate. Sed hendrerit sagittis ligula eget vulputate. Aliquam erat volutpat.

In sed vestibulum tellus.

justify

Fusce sodales gravida eros, in vulputate nulla sollicitudin sit amet. Proin volutpat ut tellus a vulputate. Sed hendrerit sagittis ligula eget vulputate. Aliquam erat volutpat.

In sed vestibulum tellus.