Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to center-justify the last line of text in CSS?

Tags:

html

css

How can I center-justify text?

Currently, justify does not center the last line.

like image 512
Voloda2 Avatar asked Jan 16 '11 10:01

Voloda2


People also ask

How do you type the last line in CSS?

The text-align-last property in CSS is used to set the last line of the paragraph just before the line break. The line break may be due to the natural ending of a paragraph, or it may be due to the use of <br> tag.

How do I center a line in CSS?

You do this by setting the display property to “flex.” Then, define the align-items and justify-content property to “center.” This will tell the browser to center the flex item (the div within the div) vertically and horizontally.

What is the last line of an HTML code?

The <hr> tag is an empty tag, which means that it has no end tag.


1 Answers

You can use the text-align-last property

.center-justified {     text-align: justify;     text-align-last: center; } 

Here is a compatibility table : https://developer.mozilla.org/en-US/docs/Web/CSS/text-align-last#Browser_compatibility.

Works in all browsers except for Safari (both Mac and iOS), including Internet Explorer.

Also in Internet Explorer, only works with text-align: justify (no other values of text-align) and start and end are not supported.

like image 105
webdif Avatar answered Oct 11 '22 23:10

webdif