HTML Paragraph with Perfect Alignment

15,195

The wrapper needs to have text justification applied via CSS:

text-align:justify;
text-justify:inter-word;

In general, browsers do a crappy job as fully-justified text compared to "typesetting" applications for print. In general, full-justification on browsers makes text HARDER to read and should generally be avoided.

css:

.justify {
    text-align:justify;
    text-justify:inter-word;
}

HTML

<div class="justify"> ...your text...  </div>
Share:
15,195
Richard
Author by

Richard

Updated on July 19, 2022

Comments

  • Richard
    Richard almost 2 years

    I want to perfectly align a paragraph so that the entire paragraph is in the center of the page but the left and right side are perfectly aligned. Here's a picture example of a paragraph that is perfectly aligned: enter image description here

    The paragraph looks like it's in a box of some sort, with perfectly straight left and right side. How do I do this in css or html?

  • Richard
    Richard over 11 years
    this is what i want but how do I also make the text in the center of the page? Should I put a div around it?
  • MikeSmithDev
    MikeSmithDev over 11 years
    set div width to whatever width you want and margin:auto and the text position will be centered on the page. <div style="width:500px;margin:auto;">
  • Richard
    Richard over 11 years
    @MikeSmithDev perfect that completes all the things that I want. Thanks so much to Diodeus too.
  • Patrick James McDougle
    Patrick James McDougle over 11 years
    Just so you know, justified text has readability implications and you should make sure that the design benefits outweigh those readability concerns.
  • jonrsharpe
    jonrsharpe about 7 years