- From: David Perrell <davidp@earthlink.net>
- Date: Thu, 4 Dec 1997 12:31:13 -0800
- To: <www-style@w3.org>
Andrew n marshall wrote:
>... CSS-1 developed several reasonable notations for
>certain types of selection that can more gracefully, and readably, be
>extended. For example , pseudo-elements and pseudo-classes were already
>used to solve the first-line and first-letter problems. Why weren't they
>used for first-child and last-child? Compare the following:
>
>CSS-2 (I think):
> DIV.sect //P/ {...}
> DIV.sect /P// {...} /* not official syntax, but suggested in a comment at
>the end of 6.6 */
>Mine (tweaked from Douglas Rand's original proposal):
> DIV.sect P:first-child {...}
> DIV.sect P:last-child {...}
Obviously, 'first-child' and 'last-child' in your example refer to
pseudo-classes, not pseudo-elements. Wouldn't ':first-sibling' and
':last-sibling' be more descriptive?
>...
>This idea does present the problem of how to specify the first-letter or
>first-line of the first-child (such as a drop-cap). The obvious solution
>screams for multiple pseudo-classes and pseudo-elements per selector.
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? E.g.:
P:first-sibling:first-letter {...}
Perhaps 'pseudo-attributes' could provide a means of specifying an element's
position in the document tree. Possibilities include:
:parent <-- immediate parent element
:ancestry <-- ordered list of ancestor elements
:first <-- no value
:last <-- no value
:index <-- numerical position among like siblings
:preceded-by <-- immediately-preceding sibling element
:followed-by <-- immediately-following sibling element
Examples:
P[:parent="DIV" :first] { /* first child P of DIV */
text-indent: 0 }
H2[:preceded-by="H1"] { /* H2 immediately following H1 */
margin-top: -.5em }
Hmm, funky characters are looking better and better.
David Perrell
Received on Thursday, 4 December 1997 15:32:04 UTC