CSS text-align-last Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The text-align-last property sets how the last line of a block is aligned — or the line right before a forced line break. Other lines still follow text-align.

It is most useful with text-align: justify, where full lines stretch to both edges but the final line often should stay start-aligned, centered, or otherwise finished cleanly. It is inherited. The initial value is auto.

Baseline · Widely available.

Not deprecated. Cross-browser since about September 2022 (Safari 16+ completed support). Safe for modern sites.

Justify tip.

Pair text-align: justify with text-align-last: left (or start) so the last line does not look stretched.

CSS Syntax

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

One keyword. auto follows text-align, except when text-align is justify — then auto acts like start.

Property Values

ValueDescriptionTry it
autoFollows text-align; with justify, behaves like startTry it
centerCenters the last lineTry it
leftAligns the last line to the leftTry it
rightAligns the last line to the rightTry it
startLogical start (left in LTR, right in RTL)Try it
justifyJustifies the last line tooTry it

How to Use text-align-last

Set the body alignment first, then decide how the final line should finish.

  1. Set text-align on the block (often justify).
  2. Choose a text-align-last keyword for the final line.
  3. Prefer start / end when direction may be LTR or RTL.
  4. Check a multi-line paragraph so the last line is shorter than full width.

Live Preview

The paragraph uses text-align: justify. Change only text-align-last and watch the final line.

Full lines stay justified. Only the last line changes.

Paragraph

Justified lines stretch to both edges of the box. Watch how the final short line moves when you change text-align-last.

text-align-last: auto

CSS Examples

Each snippet pairs text-align: justify with text-align-last so the effect is easy to see. Use Try It Yourself for a live editor.

Example 1 — Center the Last Line

Justify the paragraph, then center only the final line.

CSS
<style>
  p {
    text-align: justify;
    text-align-last: center;
  }
</style>

<p>
  Full lines meet both edges. The last line sits in the center.
</p>
Try It Yourself

How It Works

  1. Justify the block. text-align: justify stretches complete lines.
  2. Override the last line. text-align-last: center centers only that line.
  3. Need a short last line. Use enough text so wrapping leaves a shorter final line.
  4. Other lines unchanged. Only the last line (or forced-break line) uses the last-align value.

Example 2 — Left-Align the Last Line

A common pattern: justified body with a natural left ending.

CSS
<style>
  p {
    text-align: justify;
    text-align-last: left;
  }
</style>

<p>
  Justified text looks even until the last line, which stays left.
</p>
Try It Yourself

How It Works

  1. Keep justify for body lines. Full lines still meet both edges.
  2. Finish left. text-align-last: left parks the final line on the left.
  3. Close to auto. With justify, auto already acts like start — left is the physical LTR form.
  4. Readable ending. Avoids large gaps on a short last line.

Example 3 — Logical Start

Use start so the last line follows writing direction.

CSS
<style>
  p {
    text-align: justify;
    text-align-last: start;
  }
</style>

<p>Last line aligns to the start edge.</p>
<p dir="rtl">السطر الأخير يتبع اتجاه الكتابة.</p>
Try It Yourself

How It Works

  1. Logical keyword. start means the beginning of the inline direction.
  2. LTR looks like left. In English, start matches the left edge.
  3. RTL flips. With dir="rtl", start matches the right edge.
  4. Better than hard-coded left. One rule works for both directions.

Edge Cases & Pitfalls

If the last line does not change, one of these is usually why.

auto

auto + justify means start

When text-align is justify, text-align-last: auto behaves like start — not like justify.

single

One short line looks like text-align

If the block is only one line, that line is also the last line, so text-align-last and text-align can look the same.

forced

Also applies before forced breaks

A line before a forced break (for example from <br>) is treated like a last line for this property.

justify

Justifying the last line can look sparse

text-align-last: justify stretches a short final line. Prefer start or left for readability in most paragraphs.

inherit

It is inherited

A parent value can affect nested blocks. Set a local value when a child needs different last-line behavior.

Browser Support

text-align-last is a browser CSS property for last-line alignment. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

text-align-last

Chrome 47+, Firefox 49+, Safari 16+, Edge 79+. Widely available since September 2022. Older IE had only partial support.

97% Browser support
Google Chrome 47+
Full support
Mozilla Firefox 49+
Full support
Apple Safari 16+
Full support
Microsoft Edge 79+
Full support
Opera 34+
Full support
Samsung Internet 5+
Full support
Internet Explorer Partial
Partial support
text-align-last Widely supported

Bottom line: Safe for modern sites. Safari before 16 lacked support, so that release date defines Baseline. It is not a runtime API.

Key Takeaways

  • Role: align only the last line (or the line before a forced break).
  • Best with justify: finish the last line with left, start, or center.
  • auto rule: follows text-align, except justify → start.
  • Logical options: use start/end when LTR and RTL both matter.

One line: text-align-last controls the last line — pair it with text-align: justify for clean endings.

Frequently Asked Questions

It sets how the last line of a block is aligned, or the line right before a forced line break. Other lines still follow text-align.
The default is auto. The last line follows text-align, except when text-align is justify — then auto behaves like start.
text-align controls every line. text-align-last overrides only the final line (or the line before a forced break).
Justified paragraphs often leave the last line looking odd if it is forced to stretch. text-align-last lets you left-align, center, or otherwise finish that line cleanly.
Yes. It is inherited, so a value on a parent can affect nested block containers unless they set their own value.
It is Baseline and widely available since about September 2022 (Chrome 47+, Firefox 49+, Safari 16+). It is a browser CSS property, not a Node.js feature.

Next: text-decoration

Learn how to underline, overline, and line-through text.

text-decoration tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful