The text-align-last
CSS property sets how the last line of a block or a line, right before a forced line break, is aligned.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
Syntax
/* Keyword values */ text-align-last: auto; text-align-last: start; text-align-last: end; text-align-last: left; text-align-last: right; text-align-last: center; text-align-last: justify; /* Global values */ text-align-last: inherit; text-align-last: initial; text-align-last: unset;
Values
auto
- The affected line is aligned per the value of
text-align
, unlesstext-align
isjustify
, in which case the effect is the same as settingtext-align-last
tostart
. start
- The same as
left
if direction is left-to-right andright
if direction is right-to-left. end
- The same as
right
if direction is left-to-right andleft
if direction is right-to-left. left
- The inline contents are aligned to the left edge of the line box.
right
- The inline contents are aligned to the right edge of the line box.
center
- The inline contents are centered within the line box.
justify
- The text is justified. Text should line up their left and right edges to the left and right content edges of the paragraph.
Formal definition
Initial value | auto
|
Applies to | block containers |
Inherited | yes |
Computed value | as specified |
Animation type | discrete |
Formal syntax
auto | start | end | left | right | center | justify
Examples
Justifying the last line
<p>Integer elementum massa at nulla placerat varius. Suspendisse in libero risus, in interdum massa. Vestibulum ac leo vitae metus faucibus gravida ac in neque. Nullam est eros, suscipit sed dictum quis, accumsan a ligula.</p>
CSS
p {
font-size: 1.4em;
text-align: justify;
text-align-last: center;
}
Results
Specifications
Specification | Status | Comment |
---|---|---|
CSS Text Module Level 3The definition of 'text-align-last' in that specification. | Working Draft | Initial definition |
Browser compatibility
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
text-align-last
|
Chrome Full support 47 Full support 47 No support 35 — 47 Disabled' From version 35 until version 47 (exclusive): this feature is behind the |
Edge
Full support 12 |
Firefox Full support 49 Full support 49 No support 12 — 53 Prefixed' Implemented with the vendor prefix: -moz- |
IE Partial support 5.5 Partial support 5.5 Notes' IE only supports |
Opera Full support 34 Full support 34 No support 23 — 34 Disabled' From version 23 until version 34 (exclusive): this feature is behind the |
Safari No support No No support No Notes' See WebKit bug 76173. |
WebView Android
Full support 47 |
Chrome Android Full support 47 Full support 47 No support 35 — 47 Disabled' From version 35 until version 47 (exclusive): this feature is behind the |
Firefox Android Full support 49 Full support 49 No support 14 — 53 Prefixed' Implemented with the vendor prefix: -moz- |
Opera Android Full support 34 Full support 34 No support 24 — 34 Disabled' From version 24 until version 34 (exclusive): this feature is behind the |
Safari iOS No support No No support No Notes' See WebKit bug 76173. |
Samsung Internet Android
Full support 5.0 |
Legend
- Full support
- Full support
- Partial support
- Partial support
- No support
- No support
- See implementation notes.'
- See implementation notes.
- User must explicitly enable this feature.'
- User must explicitly enable this feature.
- Requires a vendor prefix or different name for use.'
- Requires a vendor prefix or different name for use.
See also
text-align-last by Mozilla Contributors is licensed under CC-BY-SA 2.5.