CSS - text-align-last Property



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

Possible Values

  • auto: Aligned as per the value of text-align.

  • start: Aligned to left if the direction is ltr and right if the direction is rtl.

  • end: Aligned to right if the direction is ltr and left if the direction is rtl.

  • left: Aligned with the left-margin (towards left).

  • right: Aligned with the right-margin (towards right).

  • center: Aligned at the center of the page.

  • justify: Aligned with both the margins.

Applies to

All the block-level elements.

DOM Syntax

object.style.textAlignLast = "start";

CSS text-align-last - Basic Example

Here is an example:

<html>
<head>
</head>
<body>
   <h2>Text Align Last</h2>
      <p style="text-align-last: left;">Text Alignment to Left.</p>
      <p style="text-align-last: right;">Text Alignment to Right.</p>
      <p style="text-align-last: center;">Text Alignment to Center.</p>
      <p style="text-align-last: start;">Text Alignment as start (left).</p>
      <p style="text-align-last: end;">Text Alignment as end (right).</p>
      <p style="text-align-last: justify; border: 2px solid red; width: 200px; height: 100px;">
         Text Justify Alignment. This alignment aligns the text based on both the margins, left and right.
      </p>
</body>
</html> 
Advertisements