CSS

🎯 CSS text-align-last Property (Last Line Alignment)

The text-align-last property in CSS defines how the last line of a text block is aligned.

It allows you to control only the final line of a paragraph, even when the rest of the text is justified.

This is useful for improving readability and visual balance in long text layouts.

💬 Simple Explanation

The text-align property controls the alignment of the entire paragraph.

But sometimes the last line looks visually unbalanced — that is where text-align-last is used.

It allows you to apply a different alignment only to the last line.

🔹 Basic Usage

CSS

p {
  text-align: justify;
  text-align-last: center;
}
                

➡️ In this example, the paragraph is justified, but the last line is centered.

🧩 Example 2 — Right Alignment

CSS

p {
  text-align: justify;
  text-align-last: right;
}
                

➡️ Here, the last line is aligned to the right while the rest stays justified.

🔸 Supported Values

1. auto

The browser automatically decides the alignment.

2. left

Aligns the last line to the left side.

3. right

Aligns the last line to the right side.

4. center

Centers the last line horizontally.

5. justify

Justifies the last line as well.

6. start / end

Aligns based on writing direction (LTR or RTL).

💡 Summary Table

Value Description
auto Browser decides alignment
left Last line aligns left
right Last line aligns right
center Last line is centered
justify Last line is justified
start / end Aligns based on text direction
  • 🧠 Summary

  • The text-align-last property controls only the last line of a text block.
  • Main difference:
  • text-align → affects entire paragraph
  • text-align-last → affects only the last line
  • It is especially useful in justified text layouts for better visual balance and readability.