RE: [css2.1] :first-line behvior

5.12.1, "The :first-line pseudo element", says that in case of nested blocks pseudo elements for all blocks should be nested inside innermost block-level element:

<div>
   <p> Abc </p>
   <p> Xyz </p>
</div>

should be processed as

<div>
   <p><div:first-line><p:first-line>Abc</p:first-line></div:first-line></p>
   <p><p:first-line>Abc</p:first-line></p>
</div>

In reality, I do not see any browser implementing this, div:first-line is ignored. Test case I used was:

   <html>
   <style>
     div             {font-family:Verdana;}
     div:first-line  {font-family:Georgia;}
     p               {color:green;}
     p:first-line    {color:blue;}
   </style>
   <body>
      <div><p>This is long paragraph that may be broken into several lines.</p></div>
   </body>
   </html>

Spec uses "should" for this behavior, and since CSSS1 and CSS2 did not specify this case, authors should not rely on this behavior. So, should this case just be removed from the spec and left unspecified?

Another interesting case is selecting style like "div:first-line span":

   <html>
   <style>
     div             {font-family:Verdana;}
     div:first-line  {font-family:Georgia;}
     p               {color:green;}
     p:first-line    {color:blue;}
     div:first-line span {font-weight:bold;}
   </style>
   <body>
   <div>
      <p>This is long <span style="display:inline-block">paragraph that may be broken into several </span>lines.</p>
      <p>This is long <span style="display:inline-block">paragraph that may be broken into several </span>lines.</p>
   </div>
   </body>
   </html>

Span style works only in Opera and only if span is set to display:inline-block, but it will apply this rule to the span even if it is on the second line and to both paragraphs. In Safari, specifying display:inline-block causes p:first-line stop working inside this span. Firefox just seems to ignore "div:first-line span" style. I would expect bold to appear for the span if it appears on first line, either inside inline-block or not, and for the first paragraph only. Am I right?

Thanks,
Sergey

Received on Wednesday, 19 March 2008 17:32:11 UTC