In HTML, can you compress a paragraph so that sentences have the same width?

I want to display a text-aligned short sentence like this.

<p style="font-size: 13px; text-align: center; width: 600px;">
This is a variable-length sentence which is sometimes only a few words and sometimes up to three lines long.
</p>

This is a sentence of variable length, which is sometimes just a few words, and sometimes even up to three lines long.

What is happening now is that because of the width, the last two words “lines long” fall into the next line of the paragraph. In centered alignment, it looks pretty ugly. My current method of solving this is to manually insert the gap in the right place.

<p style="font-size: 13px; text-align: center; width: 600px;">
This is a variable-length sentence which is sometimes<br/>only a few words and sometimes up to three lines long.
</p>

This is a sentence of variable length, which is sometimes
just a few words, and sometimes up to three lines.

, . HTML ? , "p" , , , ?

+4
1

CSS: text-align: justify;

p {
  font-size: 13px;
  text-align: justify;
}

p#first {
  width: 100px;
}

p#second {
  width: 150px;
}
<p id="first">
This is a variable-length sentence which is sometimes only a few words and sometimes up to three lines long.
</p>

<p id="second">
This is a variable-length sentence which is sometimes only a few words and sometimes up to three lines long.
</p>
Hide result
0

All Articles