W3C home > Mailing lists > Public > www-style@w3.org > February 2010

Re: text-align:justify, inline-blocks, and MS test ?inline-formatting-context-019.xht

From: Bruno Fassino <fassino@gmail.com>
Date: Tue, 9 Feb 2010 15:50:14 +0100
Message-ID: <da98bce01002090650u743622a6rb2d63230dd803a1d@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: www-style <www-style@w3.org>
On Tue, Feb 9, 2010 at 3:25 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
> On Tue, Feb 9, 2010 at 2:21 AM, Bruno Fassino <fassino@gmail.com> wrote:
>> At 9.4.2 :
>> "When the total width of the inline boxes on a line is less than the
>> width of the line box containing them, their horizontal distribution
>> within the line box is determined by the 'text-align' property.
>> If that property has the value 'justify', the user agent may stretch
>> spaces and words in inline boxes (except for inline-table and
>> inline-block boxes) as well"
>> What does the part  "(except for inline-table and inline-block boxes)"  mean?
>> I don't think it means that  "inside"  inline-tables and inline-blocks
>>  there is no stretching of spaces and words when text-align:justify.
>> I think that the Microsoft test
>> http://test.csswg.org/source/contributors/microsoft/submitted/Chapter_9/inline-formatting-context-019.xht
>> adds more confusion. It has the following assertion:
>> " If 'text-align' is set to 'justify' the user agent does not stretch
>> spaces and/or words when the 'display' property is set to
>> 'inline-block' "
>> which again seems to imply that "inside" inline-block elements spaces
>> and/or words are not stretched when 'text-align' is set to 'justify'.
>> But then the test is not really precise. The reason why the second
>> line is not stretched is simply that it is the _last_ (and the only
>> one) inside the inline-block element. The first line is instead
>> stretched because it is the first of two consecutive lines (the second
>> one including just the inline-block box, acting like a single word).
>> If some text is added inside the inline block to have two lines, then
>> stretching will occur here as well, in all browsers, see for example
>> this modified version
>> http://www.brunildo.org/test/test/inline-formatting-context-019.html).
>> Inline-block elements generate a single inline box (whose width is not
>> affected by text-align), but then inside them text-align works as
>> usual in all browsers, with possible stretching when it is 'justify'
>> and there is more than a line.  So I can't figure out what the spec
>> wanted to exclude when saying:  "(except for inline-table and
>> inline-block boxes)"
>> Maybe it simply wanted to say that the "external" single inline box
>> generated by an inline-block element is not stretched by text-align,
>> but the current words do not really say this.
> Hrm.  It sounds like it's implying that in this code:
> <inline text-align:justify;>foo foo foo <inline-block>bar bar
> bar</inline-block> foo foo</inline>
> The spaces around the foos are stretched, but it won't "reach into"
> the inline-block and stretch the bars as well.  However, if the
> inline-block had text-align:justify set on it, then it would of course
> justify the text inside of it as normal.
> ~TJ

text-align:justify is inherited. So in such a case
 - if the "bars" fit on a single line they don't stretch, but because
they are on the "last" line inside the inline-block (and this has just
the width to contain them)
 - if they need two lines, then the "bars" on the first line may stretch

I think this is the current behavior of all browsers and seems
reasonable. But it does not need that addition:
  "except for inline-table and inline-block boxes"
in the spec.


Bruno Fassino http://www.brunildo.org/test
Received on Tuesday, 9 February 2010 14:50:47 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:07:42 UTC