After re-reading the CSS2.1 and CSS3 selector specs I suspect this is impossible, but you never know.
If I can select a p element, that is a decendent of other p element using the CSS decendant selector thus:
p p {};
Is there any way to negate the decendant selector, and still select on type, so I can select p elements, except those that are decendents of other p elements…
p & ( p ! p ) {...};
i.e. I want to select elements of type p, but NOT if they decend from other elements of type p.
BTW: I am using this in querySelector() and querySelectorAll(), where each one is selected by attributes not tag type, but I wanted to show the simplest example possible…
I tried this without success (syntax error!)
p:not(p p) {......}
You suspect correctly, it is impossible.
:not(s)specifies thatsmust be a simple selector.The nearest thing you can do is to apply a style to all
pand then override it forp p.