I would like to align text to the center, but last line to the left:
section {
text-align: center;
text-align-last: left;
}
It works well, but what if there is only one line? In this case, I would like to align text to the center, which doesn't work, because the first line is also last line. Is there any selector for elements with only multiline text or selector for first line (not pseudo-element :first-line
)?
Live Example:
section {
text-align: center;
text-align-last: left;
width: 300px;
}
<strong>This works:</strong>
<section>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam aliquam turpis consectetur diam fringilla, vel ultrices sapien bibendum. Maecenas pulvinar in nisl at mattis. Duis nisi risus, rhoncus sit amet ornare malesuada.</section>
<strong>Next line should be centered (something like text-align-first?):</strong>
<section>Lorem ipsum dolor sit amet.</section>