W3C home > Mailing lists > Public > www-style@w3.org > April 2000

Extensions to CSS3 selectors

From: Jonas Sicking <sicking@bigfoot.com>
Date: Fri, 21 Apr 2000 22:12:08 +0200
Message-ID: <011e01bfabcd$e283d840$3110f7d4@Milwork08>
To: <www-style@w3.org>

I have some suggestions for extensions to the current CSS3 selector WD:

1. Empty cells
Some way of selecting empty elements, my suggestion is a pseudo-class called
':empty'. This could be used to supply defaultvalues through CSS and also
functions like marking of missing data and more powerful hanling of empty
cell then the current 'empty-cells' property.

2. nth-of-type ranges
Some variant of nth-child(n) and nth-of-type(n) to select a range of
positions rather then just one specific position. My suggestion is:
E:nth-of-type(2 to 20)
and possibly even
E:nth-child(3-7,10 to 20,30)

E:nth-child(10 to 5) could either be the same as :nth-child(5 to 10) or
match no element. I suggest that it would match no element since that is
proboly most easy to implement (and has other advantages as described

3. nth-of-type from bottom
Some way to specify the nth-child(n) position based on position from bottom
of the document. That way we could do things like 2nd-last-of-type. I think
there are two ways of doing this (both select the 2nd last E):

Where the second one would allow really powerful range selections like:
TABLE > TR:nth-of-type(3 to -3)
Which would select every TR that has position third first to third last (ie
not the two first and not the two last). This does however give the problem
when there are only four TR elemnt within the TABLE. I think that the in
that case the selector shouldn't match any elements.
The above selector could therefor be considered eqivalent to
TABLE > TR:nth-of-type(3 to 2)
if such a range would match no element (as suggested above).

4. A UI-default pseudo-class
A psudoclass that selects the element that will be activated when the user
selects the hits a activate key (Enter on most platforms). This would allow
for marking of default buttons in forms. Internet Explorer does this by
outlineing the key with a thicker black border.

5. Negated psudo-classes
Many pseudo classes could also be useful negated like just like first-child
has not-first child. Some examples are contains, nth-child, lang and root.
One way of doing this is having not-contains, not-nth-child, not-lang etc
pseudo classes. Another is by having a general pseudo-class inverter like
suggested in http://lists.w3.org/Archives/Public/www-style/1999Feb/0049.html

Netagion can also be useful on elements like:
!E > F matches any F that dosn't have an E as parent
!E:only-child > F matches any F that dosn't have a only-child-E as parent
(unlike "E:!only-child > F" which is the same as "E:not-only-child > F")

however really advanced selector can be done like:
!E:!nth-of-child(3):!hover > F:subject + !G
which might be too hard to implement?

6. XPath
This might be way to hard to implement but I think it is a neet idea to
allow XPath expressions (combined with pseudo-classes) as CSS selectors...

/ Jonas Sicking
Received on Friday, 21 April 2000 16:11:51 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:26:54 UTC