This is driving me nuts:
HTML:
<div><h1>Hello World!</h1></div>
CSS:
*:not(div) h1 { color: #900; }
Doesn't this read, "Select all h1
elements that have an ancestor that is not a div
element...?" Thus, "Hello World!" should not be coloured red, yet it still is.
For the above markup, adding the child combinator works:
*:not(div) > h1 { color: #900; }
But doesn't affect the h1
element if it is not a child of a div
element. For example:
<div><article><h1>Hello World!</h1></article></div>
Which is why I'd like to indicate the h1
element as a descendant, not a child, of the div
element. Anyone?
*
, i.e.:not(div)
, just like how you specify.class
or#id
without the*
. – Gallaway