Justified paragraphs expand inter-word spacing, but I expected
to be unaffected by this expansion. Unfortunately, it is affected, and so I need to find an unaffected space character (preferably one with the same width as an ordinary space in an ordinary left-justified paragraph). Any suggestions?
The zero-width space (), abbreviated ZWSP, is a non-printing character used in computerized typesetting to indicate word boundaries to text-processing systems in scripts that do not use explicit spacing, or after characters (such as the slash) that are not followed by a visible space but after which there may ...
For example, the common whitespace symbol U+0020 SPACE (also ASCII 32) represents a blank space punctuation character in text, used as a word divider in Western scripts.
Commonly the preferred word space used is a thin space of 1/8 the em. Some French typographers prefer to use a larger space character of 1/4 the em with the colon and some other punctuation characters.
You could just add a character such as .
and make it invisible.
It works. jsFiddle here
It is not parsed as whitespace, since it is technically a character that just isn't visible.
For a cleaner method, you could insert the character via the :after
pseudo element..
span:after {
content: ".";
visibility: hidden;
}
jsFiddle here
The rendering of space characters other than SPACE and NO-BREAK SPACE is not defined in HTML specifications. In practice, various fixed-width spaces can be used, and they are not expanded in justification (effectively, they are treated as graphic characters, just with empty glyphs). The one that most closely matches a normal space in width is FOUR-PER-EM SPACE,  
, but from the comments, it seems that you would rather want to use THIN SPACE or SIX-PER-EM SPACE.
Previously, browsers used to treat NO-BREAK SPACE as non-expansible, and some may still do, but for some odd reason, most browsers have abandoned this sensible idea. There is no guarantee that they won’t do the same to fixed-width space.
Apart from the theoretical point and the risk mentioned, fixed-width spaces suffer from font problems and breakability. The font problems mainly apply to old versions of IE, and the breakability (i.e., fixed-width spaces are treated as allowing a line break after them) could be addressed by using NARROW NO-BREAK SPACE if its width suits you and you take the risk with the font issue.
So it is probably best to do the spacing in CSS, even though it means a bit more work. For e.g. “e.g.” with spacing after the first period, you would need to decide whether it should be “e.g.” or “e. g.” at the character level. In the former case, just wrap the first period in a span
and set padding-right
on it. In the latter case, you could e.g. use e.<span class=thin> </span>g.
and set the width of the span
to something sufficiently small (using display: inline-block
and a width
setting).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With