W3C home > Mailing lists > Public > www-style@w3.org > April 2012

Re: [css3-text] ISSUE-229 Combining justification and whitespace:pre*

From: Bert Bos <bert@w3.org>
Date: Wed, 11 Apr 2012 14:24:07 +0200
To: www-style@w3.org
Message-Id: <201204111424.07987.bert@w3.org>
On Tuesday 20 March 2012 00:22:18 Tab Atkins Jr. wrote:
> [Fixed subject to have the spec indicator]
> Right now, CSS 2.1 specifies that text-align:justify doesn't do
> anything when combined with whitespace:pre or pre-wrap.  As far as I
> can tell, this was done due to no one having any good use-cases (and
> thus no one knowing how it should really work in some cases).
> I've been contacted by some internal people about this, because
> they're working on docs stuff.  They want to both (a) preserve the
> spaces that the user has typed in, like desktop word-processing
> software does, and (b) justify text when the user requests it.  (a)
> can only be done with a whitespace value.  (You can't use &nbsp;,
> because then things don't break properly.)
> The troublesome case seems to be combining all of this with tabs,
> because you want tab-stops to still line up between lines.  MS Word's
> behavior is to only justify the part of the line that comes after the
> last tab character on the line, and my internal people say that's
> fine for them too.
> Are there any other issues with this that we can resolve while I have
> the ear of relevant people?  If not, can we relax this restriction in
> Text?

I don't really see why you'd want to have different widths for the 
spaces on a line, unless it is in monospaced text, but if somebody wants 
to define a new meaning for the combination of 'pre' and 'justify', I 
don't see any harm.

There is, however, the problem of backwards compatibility. For HTML, we 
can add 'PRE {text-align: left}' to the default style for HTML in 
appendix D. But what about XML-based formats that don't have a default 
style sheet?

My mental model for 'white-space: pre' is different. I think of it as 
something that changes spaces from being mark-up to being characters.

Without 'pre', the spaces serve as word separators. They aren't actually 
rendered, they just indicate where a word ends or begins. Two words on 
the same line then get a more or less flexible amount (depending on 
other properties) of empty space between them. I.e., it's not the space 
that is replaced by flexible empty space, it is the boundary between 
words. And if the font has a glyph for U+0020, it is not used.

With 'pre', the spaces are no longer mark-up, but characters to be 
rendered, with exactly the size specified in the font (plus or minus 
'letter-spacing', but unaffected by 'word-spacing'), exactly as any 
other character. And if the font happens to have a glyph for U+0020 that 
actually produces ink, then you will see that ink rendered.

In other words, if you try to justify text with 'white-space: pre', the 
whole line consists of a single "word" and there is nowhere to insert 
flexible empty space. All you can vary is the letter spacing. (In level 
3, 'text-justify' will determine if letter spacing is actually flexible 
or not.)

  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos                               W3C/ERCIM
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France
Received on Wednesday, 11 April 2012 12:24:38 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:14 UTC