tags:

views:

249

answers:

2

I want to select all descendant elements of the element with class="x" this way:

<!DOCTYPE html>
<html>
<head>
  <style type="text/css">
    .x * {
      color: red;
    }
  </style>
</head>
<body>
  a
  <p>
    b
     <p class="x">
        c
        <p> should be red </p> foo
     </p>
  </p>
</body>
</html>

which unfortunately does not apply to those elements. neither *.x * does.

what am i doing wrong?

+3  A: 

You can't have a <p> in a <p>. Try changing your inner <p> tag to a <span> tag.

Hope this helps

mattbasta
you're right, but w3 validator did not told me so :-/ changing p's to div's works now. thanks
mykhal
A: 

Try:

.x > *{

     /* some styles here */

}
Austin Fitzpatrick