5

As far as I know CSS selectors get evaluated from right to left, so body div * would select every item, than look which has a parent of type div and of those which has a parent of type body. What I am uncertain about is how dynamic pseudo-classes get evaluated in this chain.

If I had a selector like div *:hover how would the evaluation be?

  1. :hover => * => div
  2. *=> :hover => div
  3. Another solution I didn't think about
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Daniel Schmidt
  • 11,605
  • 5
  • 38
  • 70
  • 2
    Probably, that's implementation dependent. – Oriol Mar 12 '15 at 16:06
  • 4
    The evaluation actually looks more like `*:hover` => ancestor `div` for a typical implementation. There is no notion of order within an individual compound selector, except the order of which simple selectors would be easiest to match, and that is decided by 1) what simple selectors are in use, and 2) the implementation. See these answers: [\[1\]](http://stackoverflow.com/a/5813672) [\[2\]](http://stackoverflow.com/a/10108700) Note that this question is about dynamic pseudo-classes, which makes it more interesting, even if ultimately it still concerns implementation details. – BoltClock Mar 12 '15 at 16:11

1 Answers1

-1

Unfortunately,

* => :hover => div

The universal selector is evaluated first, which means it looks at every element in the DOM, then checks to see if it's in a :hover state. Finally, for any matching elements, it then checks for a parent div.

Randy Hunt
  • 435
  • 3
  • 10