I have the following code:
.clJustify {
width: 400px;
height: 25px;
margin-left: auto;
margin-right: auto;
border: 1px solid red;
text-align: justify;
}
.clJustify:after {
content: "";
display: inline-block;
width: 100%;
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Justify Test</title>
</head>
<body>
<p class="clJustify">This is text that should be jus-</p>
<p class="clJustify">tified and also hyphenated.</p>
</body>
</html>
Please don’t ask me why I want to do this. :-)
My problem is: In FF and Chrome this results in two lines of text that fill the space of the <p>
. But IE breaks the first line before the “jus-” and puts it into a separate line. A line without a hyphen will be displayed as expected, it is the hyphen at the end that confuses IE, it seems.
Here is a screenshot from Internet Explorer:
And here is a screenshot from Firefox:
Any ideas how I could prevent IE from breaking the line? The suggested answers to older posts don't address the problem of the hyphen.