W3C home > Mailing lists > Public > www-style@w3.org > December 1997

Re: Selector Readabiliitiy [sic]

From: David Perrell <davidp@earthlink.net>
Date: Thu, 4 Dec 1997 19:00:49 -0800
To: <www-style@w3.org>
Message-ID: <01bd0129$fd918020$7b75d9cf@davidp>
Liam Quinn wrote:
>At 12:31 PM 04/12/97 -0800, David Perrell wrote:
>>The spec states that "only one pseudo-element can be specified per
>>selector." No mention of pseudo-classes. Can a pseudo-element apply to a
>>pseudo-class?
>
>Yes, according to the CSS1 grammar (http://www.w3.org/TR/REC-CSS1#appendix-
>b).  The pseudo-element must follow the pseudo-class.

Thank you.


I suggest that :first and :last pseudo-classes are preferable to the
double-slash first child syntax described in 6.6[1].

----
:first and :last pseudo-classes

The :first pseudo-class applies to the first among siblings of the same
element type. The :last pseudo-class applies to the last among siblings of
the same element type.

In the following example, the first child P of any element will have no
text-indent. The last child P of any element will have italic text.

  P:first { text-indent: 0 }
  P:last { font-style: italic }
----

In the following example, a TABLE that immediately follows the first child
H2 of a DIV will be floated right:

  DIV ~/H2:first ~TABLE/ { float: right }

TABLE will match even if H2 is not the very first child element of DIV:

  <DIV>
  <P CLASS=preamble>A bit of preamble</P>
  <H2>The following table will float right</H2>
  <TABLE>
  ...

Is the previous selector equivalent to the following?

  DIV ///H2/ ~TABLE/ { float: right }

It's not clear to me whether //H2/ matches the first child H2 or the first
child IF it is H2. Whichever, the plethora of slashes can get a mite bit
confusing.

David Perrell

[1] http://www.w3.org/TR/WD-CSS2/selector.html#h-6.6
Received on Thursday, 4 December 1997 22:01:10 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:53:53 GMT