Align the Last Line of Text with This Little-Known CSS Trick

Example showing justified paragraph with the last line aligned to the end using text-align-last in CSS

Did you know you can align just the last line of a paragraph?

Most developers are familiar with text-align. But there’s a lesser-known CSS property that gives you more control.

This lets you style the final line of text differently from the rest. Here’s how it works:

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

—> All lines are justified, except the last one, which aligns to the end.

The best part? A solid 95.28% across modern browsers. So yes, it’s production-ready.


I’m working on an ebook called “You Don’t Need JavaScript”.

To get notified when it launches 👉 https://theosoti.com/you-dont-need-js/

Related Articles

Explore more articles on front-end development, covering HTML, CSS and JavaScript for building high-performance websites.

    No strings attached, unsubscribe anytime!