0

I have a HTML page with contents (div, h1, ...). With interaction on one of these contents I would like to affect my body. I look at ~ and + sibling symbol for CSS but without success.

Is there a way to achieve what I want to do ?

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Pierre
  • 10,593
  • 5
  • 50
  • 80

1 Answers1

4

CSS provides nothing that allows you to modify an element based on its children or elements that follow it.

You'll need to look to JavaScript for that.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • You're wrong about the second part. You have `~` and `+` for preceding elements before and after accordingly. You are correct about the fact that you can't "modify an element based on its children". http://generaldisarray.wordpress.com/2006/05/02/introduction-to-css-combinators/ – iMoses Nov 11 '12 at 19:27
  • 2
    @iMoses — No. `A+B` selects `B` if the immediately previous sibling was `A`. `A~B` selects `B` if any previous sibling was `A`. `B` must be **after** `A`. Neither of them select an element because something follows it. – Quentin Nov 11 '12 at 19:30
  • What do you mean by "something follows it". perhaps I don't understand you correctly. "immediately previous sibling" - doesn't it means that B follows A. I agree about the "immediately" part, but it still follows. – iMoses Nov 11 '12 at 19:44
  • 1
    @iMoses — B follows A and you are selecting B not A. You can select an element based on what the element you are selecting follows. You can't select an element based on what follows the element you are selecting. – Quentin Nov 11 '12 at 19:46
  • @iMoses: Some illustrations... http://stackoverflow.com/questions/3382078/what-does-mean-in-css/3382096#3382096 http://stackoverflow.com/questions/10737114/and-expressions-in-css/10737139#10737139 – BoltClock Nov 13 '12 at 17:09