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

[css-display][css-pseudo] run-in & ::first-letter

From: Florian Rivoal <florian@rivoal.net>
Date: Thu, 12 Feb 2015 19:22:57 +1100
Message-Id: <B81F7808-D972-458D-970F-3900E82A0F27@rivoal.net>
To: www-style list <www-style@w3.org>
We briefly discussed the interaction of display:run-in and ::first-letter during the f2f without reaching a conclusion.

Given the following markup & styling, it is not clear what will happen:

<style>
h1, h2 {display: run-in; }
h1::first-letter { color: green; }
h2::first-letter { color: orange; }
p::first-letter { color: blue; }
</style>

<h1>First title</h1>
<h2>Second title</h2>
<p>Lorem ipsum</p>


CSS2.1 says:
  The :first-letter pseudo-element must select
  the first letter
  of the first line of a block,
  if it is not preceded by any other content
  (such as images or inline tables) on its line.

and css-pseudo says:

  The ::first-letter pseudo-element represents
  the first typographic letter unit
  on the first formatted line of its originating element,
  if it is not preceded by any other content
  (such as images or inline tables) on its line.

p::first-letter should certainly not select 'L' and make it blue, as it is not "the first typographic letter unit on the first formatted line" or "The first letter of the first line of a block", and regardless of spec wording, it would be a bad idea for 'L' to be selected here.

Whether p::first-letter and h1::first-letter should select 'F' or nothing is a lot less clear to me, but I believe that at least one should.

Given that 
  <style>
  p::before {content: "A";}
  p::first-letter {color:green;}
  </style>
  <p>Lorem ipsum</p>
makes 'A' green, p::first-letter should match 'F' in the first example. Arguably this is already what the spec says, but the wording does not seem clear-cut to me.

As for "h1::first-letter", I am not sure what the what the spec intends, but it seems reasonable and useful that it would also match 'F'.

Finally, it seems clear to me that h2::first-letter should not select 'S', and I also don't think it would be good for it to select 'F'.

Should we fix/clarify the specs so that both p::first-letter and h1::first-letter match 'F', or does someone believe another behavior would be preferable?

 - Florian
Received on Thursday, 12 February 2015 09:22:22 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:28 UTC