Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to justify text in Firefox and Safari with CSS?

In Chrome, on a paragraph element,

text-align: justify;

works fine and creates a block alignment, but has no effect in Firefox or Safari. Any suggestions?

like image 495
THX1137 Avatar asked Aug 03 '18 01:08

THX1137


People also ask

How do you justify text align in CSS?

The text is justified by adding space between words (effectively varying word-spacing ), which is most appropriate for languages that separate words using spaces, like English or Korean.

How do you justify text in a web page?

The align attribute of <p> tag is used to justify the text on a web page. This can be done by assigning the value to the aligned attribute as justified.

Why is text align justify not working?

If your text doesn't span more than one line, justifying doesn't do anything. Your text has to wrap to the next line, and then the FIRST line will be justified, but not the second.


1 Answers

Set the white-space property to pre-line. It will force to collapse into a single whitespace and the text will wrap on line breaks. This will help to block align:

   white-space: pre-line;
like image 112
Vega Avatar answered Sep 24 '22 11:09

Vega