I'm looking for a clever trick to select elements either strictly by their nesting depth, or by both ordinal position and nesting depth. In other words, increment n for each nth descendant of an element (or even nth-of-type) rather than just siblings. In the above example I tried and failed to get that RGB sequence to work across depths.

I've run across this problem a few times. One practical application might be to alternate between horizontal and vertical CSS menus for odd and even submenus by selecting a ul by nesting depth. I attempted this for a CSS menu but it didn't quite work. (structure comes from the HTML tree and otherwise uses generated content / counters... fails hilariously in IE of course.)

I don't really know javascript yet but it would still be interesting to see a pure CSS way.

(first post, hi)