CSS text-align-last Property
Sets how the last line of a block or a line right before a forced break is aligned
Syntax
text-align-last: auto | start | end | left | right | center | justify;Values
| Value | Description |
|---|---|
| auto | Uses text-align value (default) |
| start | Aligned to writing-direction start |
| center | Centered |
| justify | Justified |
Example
.justified {
text-align: justify;
text-align-last: center;
}Understanding CSS text-align-last
The CSS text-align-last property sets how the last line of a block or a line right before a forced break is aligned. As part of the Typography module in CSS, it is one of the most commonly used properties for controlling the visual presentation of web pages.
You can set text-align-last to values such as auto, start, center, justify, among others. Each value changes how the browser renders the affected element, giving you fine-grained control over your page layout and design. Choosing the right value depends on the specific design requirements of your project.
Common use cases for the text-align-last property include responsive web design, component-based layouts, and creating visually consistent interfaces across devices. It works closely with related properties like text-align, text-indent, direction to achieve complex styling effects. Understanding how these properties interact helps you write cleaner, more maintainable stylesheets.
Browser support for text-align-last is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. For older browsers, consider using fallback values or progressive enhancement strategies. The property can also be set dynamically via JavaScript using element.style.textAlignLast or the CSS custom properties (variables) approach for theming.
Related Properties
Explore More CSS Properties
Browse our complete reference of 251 CSS properties with syntax, examples, and tips.