X

Headline

This is an important message requiring you to make a choice if you're based in the EU.

CSS text-align-last Property

The CSS text-align-last property sets the alignment of the last line of the text.

The text-align-last property is one of the CSS3 properties.

The text-align-last property sets the alignment for all last lines within the selected element. If a <div> with three paragraphs in it, the text-align-last will apply to the last line of each of the paragraphs.

This property is supported with prefix -moz- for Firefox 12-Firefox 48, and is supported without prefix for Firefox 49-Firefox 65.

Initial Value auto
Applies to Block containers.
Inherited Yes.
Animatable No.
Version CSS3
DOM Syntax object.style.textAlignLast = "left";

Syntax

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

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      div{
      text-align: justify;
      -moz-text-align-last: right; /* For Firefox prior 58.0 */
      text-align-last: right;
      }
    </style>
  </head>
  <body>
    <h2>Text-align-last property example</h2>
    <h3>text-align-last: right:</h3>
    <div>
      Lorem Ipsum is dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    </div>
  </body>
</html>

Another example where "start", "justify" and "center" values are included:

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      div.example1 {
      text-align: justify; /* For Edge */
      -moz-text-align-last: start; /* For Firefox prior 58.0 */
      text-align-last: start;
      }
      div.example2 {
      text-align: justify; /* For Edge */
      -moz-text-align-last: center; /* For Firefox prior 58.0 */
      text-align-last: center;
      }
      div.example3 {
      text-align: justify; /* For Edge */
      -moz-text-align-last: justify; /* For Firefox prior 58.0 */
      text-align-last: justify;
      }
    </style>
  </head>
  <body>
    <h2>Text-align-last property example</h2>
    <h3>Text-align-last: start:</h3>
    <div class="example1">
      Lorem Ipsum is dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    </div>
    <h3>Text-align-last: center:</h3>
    <div class="example2">
      Lorem Ipsum is dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    </div>
    <h3>Text-align-last: justify:</h3>
    <div class="example3">
      Lorem Ipsum is dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s  when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    </div>
  </body>
</html>

Values

Value Description
auto The last line is aligned to the left.This is the default value of this property.
left Aligns the last line to the left.
right Aligns the last line to the right.
center Aligns the last line to the center.
justify The last line is justified as the other lines.
start The last line is aligned at the beginning of the line.left if direction is left-to-right and right if direction is right-to-left.
end The last line is aligned at the end of the line. Right if direction is left-to-right, left if direction is right-to-left.
initial Makes the property use its default value.
inherit Inherits the property from its parents element.

Browser support

47.0+ x 49.0+
12.0-48.0 -moz-
x 34.0+

Practice Your Knowledge

If a <div> with three paragraphs in it, the text-align-last will apply to the



Do you find this helpful?

Related articles