Re: [CSS21][css3-text] letter-spacing, word-spacing and justification

Alan Stearns <stearns@adobe.com> wrote on 2013/01/17 13:41:47
> On 1/16/13 7:41 PM, "MURAKAMI Shinyu" <murakami@antenna.co.jp> wrote:
> 
> >I often see the following CSS code, I think this has a problem:
> >
> >p {
> >  letter-spacing: 0pt;
> >  word-spacing: 0pt;
> >  text-align: justify;
> >}
> >
> >In the CSS2.1 and CSS3 Text, the initial value of letter/word-spacing is
> >'normal', stretchable in justification, and different from the fixed
> >value 0pt. See the spec:
> >
> >CSS2.1
> >http://www.w3.org/TR/CSS2/text.html#spacing-props
> >    'letter-spacing'
> >    ...
> >    normal
> >      ... This value allows the user agent to alter the space between
> >characters in order to justify text.
> >    <length>
> >      ...  User agents may not further increase or decrease the
> >inter-character space in order to justify text.
> >
> >CSS3 Text
> >http://www.w3.org/TR/css3-text/#spacing-limits
> >    <spacing-limits> = [ normal | <length> | <percentage>]{1,3}
> >      ... If just one value is specified, then it represents the optimum,
> >minimum, and maximum.
> >http://www.w3.org/TR/css3-text/#text-justify
> >    ... If the inline contents of a line cannot be stretched to the full
> >width of the line box, then they must be aligned as specified by the
> >'text-align-last' property. (If 'text-align-last' is 'justify', then they
> >must be aligned as for 'center' if 'text-justify' is 'distribute' and as
> >'start' otherwise.)
> >
> >
> >My questions:
> >- Is my understanding of the spec correct?--If the value of
> >letter/word-spacing is '0pt', the <spacing-limits> is
> >optimum=minimum=maximum=0pt and cannot be stretched in text justification.
> 
> I can't speak to CSS2, but in CSS3 Text you have this sentence:
> 
> ---
> The text justification process may alter the spacing from its optimum
> (see the 'text-justify' property, above) but must not violate the minimum
> spacing limit and should also avoid exceeding the maximum.
> 
> 
> ---
> 
> So with optimum=minimum=maximum=0pt in justified text the 'added' spacing
> must not go below 0pt, but it is allowed to go above 0pt when it's
> impossible to justify the line without breaking the spacing constraints.

Thanks for your comment.

In my understanding, "should also avoid exceeding ..." in the spec 
means nearly "not allowed". Please note that the spec also says:
"If the inline contents of a line cannot be stretched to the full
width of the line box, then they must be aligned as specified by the
'text-align-last' property."

The initial value 'auto' of text-align-last is same as 'start' 
when text-align is 'justify', and if all letter/word-spacing in
the inline contents of a line has optimum=minimum=maximum=0pt, 
it cannot be stretched and the result will be same as text-align:start.

So I raised the question:
>> - I tested major browsers with the following samples and found 
>> that they stretch the fixed value spacing, the value '0pt' is 
>> treated like 'normal'. Is this behavior wrong and should be 
>> corrected? (or the CSS spec is wrong?)
>> https://dl.dropbox.com/u/64715801/word-spacing-justify.html
>> https://dl.dropbox.com/u/64715801/letter-spacing-justify.html

Regards,

Shinyu Murakami
Antenna House

Received on Monday, 21 January 2013 13:45:17 UTC