# Archive — hermiene.net

"Ooh, that thing has numbers on it."

### October 2, 2004

A pretty interesting pseudo-class has been discussed on and off on www-style. Although I haven't found a need for it myself (not that that's relevant), people apparently want a parent selector. Several proposals have been made:

• Modify the subject of the selector chain with :subject: .section ul:subject > li { ... }
• Modify the subject of the selector chain with parentheses: .section (ul) > li { ... }
• Modify the subject of the selector chain with the dollar sign: .section \$ul > li { ... }
• The :matches() pseudo-class.

The first proposal is fundamentally flawed; :subject isn't a pseudo-class in any sense, it's a modifier. Also, the first three proposals all suffer from the same thing: they break what's been consistent since CSS1; the last part of the selector chain is what's being selected. So far, my favorite is :matches(). With this, you can use look-ahead assertions to determine whether or not to select the element. Say you want to select <ul>s that are descendants of any element with the class attribute set to section, and you want to require that the <ul>s have <li> children (like in the first three examples). This is done like this: .section ul:matches(# > li) { ... }. Here, the # is referring to the element that's trying to be matched (the <ul>). What's more, :matches() takes an arbitrary amount of comma-separated selectors to try to match, of which at least one has to actually match for the element to be selected: .section ul:matches(# > li.note, # > li.important, # dl.compact) { ... }. And if that wasn't enough, :matches() can be nested arbitrarily. You know what, I can't think of an example where one would use nested :matches()s, but the ability is there. :-P

On another note, the first Wilburer has arrived.

"Every facet, every department of your mind is to be programmed by you, and unless you assume your rightful responsibility, and begin to program your own mind, the world will program it for you."