Re: body:first-char and specificity of selectors

<<
BODY { color: red }
BODY:first-line { color: blue }
EM:first-char { font-size: bigger }
...

<BODY>
<P>Hello this is some text.  Is the first-line of this text red or
blue?  And also, does <EM>First-char</EM> work anywhere, or does it
only apply to the first character of each new block level element?
>>

Doesn't a block-level element begin a new line? If so, BODY has no
:first-line pseudo-element and the first line of P is red.

":first-char" or ":first-letter"? The CSS2 draft states that ":first-line"
and ":first-letter" can only be attached to block elements. (Why the
restriction, I wonder?)

<<
Which is of a higher specificity:

P:first-char EM
or
P EM:first-char
?
That is, which would be applied to
<P><EM>Hey!</EM>
>>

According to the CSS2 draft, both declarations are no-nos, even if you mean
":first-letter" rather than ":first-char". The first letter of P has no
offspring so EM would never match, even if the draft did not state that
"pseudo-elements may only appear as the last segment of a selector".

David Perrell

Received on Wednesday, 17 December 1997 19:29:26 UTC