Re: [CSS21][css-text] percentages on text-indent

On 2/11/15 7:50 AM, Jonathan Kew wrote:
> Fair enough! But here's a testcase where Firefox differs from Chrome and
> Safari:
>
> http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=3414

Oh, this is exciting.

What's going on here is that if you have this markup:

   <div style="width: 200px">
     <div style="width: 100px; text-indent: 50%">
        Text
     </div>
   </div>

then WebKit/Blink will indent the text by 100px, because they're 
following the spec and using the containing block.  So far so good.

Now if you have this markup:

   <div style="width: 200px">
     <div style="width: 100px; text-indent: 50%">
        Text
        <div></div>
     </div>
   </div>

then WebKit/Blink wrap the text in an anonymous block, as if the markup 
had been:

   <div style="width: 200px">
     <div style="width: 100px; text-indent: 50%">
        <div>Text</div>
        <div></div>
     </div>
   </div>

and then I assume they inherit the text-indent into that anonymous 
block.  text-indent inherits as a percentage, so that anonymous block 
gets "text-indent: 50%", which is resolved relative to its containing 
block, so you get a 50px text-indent.

On the face of it, the fact that adding a block after the text changes 
the indent behavior is clearly wrong conceptually.

In spec terms, this is a longstanding issue with 
<http://www.w3.org/TR/CSS21/visuren.html#anonymous-block-level> in that 
I can't even claim that the Blink/WebKit behavior is not following the 
current spec.  I could have sworn it had come up before, but I can't 
seem to find the discussion right now.

Note, also, that we _do_ want text-indent applying to anonymous blocks. 
  See for example the thread at 
<https://groups.google.com/forum/#!topic/mozilla.dev.tech.css/D2XbVpXMDUM>. 
  So the real question is what that text-indent should be, not whether 
it should happen at all.

-Boris

Received on Wednesday, 11 February 2015 15:40:49 UTC