Re: When is a first letter not a :first-letter?

fantasai wrote:
> 
> Simon Montagu wrote:
>>
>> The section on "The :first-letter pseudo-element" at 
>> http://www.w3.org/TR/CSS21/selector.html#x53 and parallel sections in 
>> other CSS versions nowhere specifies whether there is any restriction 
>> on which characters can be selected by :first-letter, or in other 
>> words, what is the definition of "letter" for the purposes of this 
>> section.
>>
>> It does specify that the ':first-letter' also applies if the first 
>> letter is in fact a digit, e.g., the "6" in "67 million dollars is a 
>> lot of money.", and to me this seems to imply that it does not apply 
>> if the first character is neither a digit nor a letter, e.g. the "$" 
>> in "$67,000,000 is a lot of money". It would be clearer if this was 
>> defined explicitly in terms of Unicode character classes, as with 
>> punctuation in the previous paragraph.
>>
>> In practice, user agents seem to apply :first-letter to either the 
>> first  character (plus leading punctuation) regardless of character 
>> class, or in the worst case to the first UTF-16 code unit.
> 
> There's a line there
>   # Punctuation (i.e, characters defined in Unicode in the "open" (Ps),
>   # "close" (Pe), "initial" (Pi). "final" (Pf) and "other" (Po)
>   # punctuation classes), that precedes or follows the first letter
>   # should be included.

Yes, and what I am proposing is to add something like:

|':first-letter' applies if the first letter is a letter or a digit
|(i.e. characters defined in Unicode in the "uppercase" (Lu),
|"lowercase" (Ll), "titlecase" (Lt) and "other" (Lo) letter classes and
|the "decimal digit" (Nd), "letter" (Nl) and "other" (No) number
|classes).

Making that list alerted me to an issue I hadn't thought of before: 
characters in the modifier letter (Lm) class should probably not be 
considered a first letter in themselves, but should be included with the 
first letter even if they don't form a grapheme cluster.

Another question is what should happen if the first letter is preceded 
by a sequence of punctuation and whitespace. This is tricky because in a 
case like:

<p>" This is a quotation "</p>

it seems reasonable for :first-letter to apply to '" T', but in a case like

<p>"*" is an asterisk</p>

it doesn't seem so reasonable for :first-letter to apply to '"*" i'.

Received on Sunday, 29 June 2008 08:13:56 UTC