While it's not very common to see web pages these days use justified text, some websites that publish research, scientific articles, studies, etc., may employ it. Presenting paragraph text in a justified manner can be a way to give a more formal and distinctive impression compared to the rest of web pages.
Personally, I wouldn't recommend any website to justify their content. In this article, you have an explanation of why this is generally not a good idea. Link to the article
Justify Text with text-align: justify;
The property we should use to justify text is text-align followed by the value justify, as in the following example:
<p class="text-justify">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the standard dummy text of the industry since the year 1500, when an unknown printer (N.B. a person involved in printing) used a gallery of texts and mixed them in such a way that he managed to create a specimen book of texts.</p>
.text-justify {text-align: justify;}
Example with all paragraphs justified.
Justify text directly in HTML using inline styles
Although using inline styles is not the recommended way to insert CSS in HTML, it is necessary to know how to do it because sometimes we must resort to this method.
<p style="text-align: justify;">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the standard dummy text of the industry since the year 1500, when an unknown printer (N.B. a person involved in printing) used a gallery of texts and mixed them in such a way that he managed to create a specimen book of texts.</p>
Justifying text with the deprecated HTML align attribute
While researching to write this post, I found some articles on forums and other pages where they used the HTML align attribute to justify the text, as in the following examples:
<p align="justify">This is the paragraph in which the text will be justified.</p><div align="justify">Div tag with justified text.</div>
Needless to say, the align attribute should no longer be used as it is obsolete, and there are methods like the ones mentioned earlier that are the current standards.
I am Juneiker Castillo, a passionate front-end web developer deeply in love with programming and creating fast, scalable, and modern websites—a JavaScript enthusiast and a React.js lover ⚛️.
About me