Re: a recall for a missing combinator

On 11/15/2011 12:44 AM, Niels Matthijs wrote:
>
> *The (partial) solution*
>
> **
>
> Translating my need to a practical solution may not be all that easy. The closest I get is looking for the first nested
> instance and target all matches on that level:
>
> article.product (?) header {…}
>
> This should match the first nested instance of the header, ignoring whatever levels that come in between .product and header,
> but failing to match the header in article.review
>
> *Problems with the solution above*
>
> I know this is not a full fix for my problem. If I have <p> elements nested on several levels nested inside the
> article.product I still can’t style them differently from the <p> elements inside the article.review. This would call for a
> way where css could define an actual scope. While I think this could be incredibly powerful, it’s also destructive in the
> wrong hands.

If I relaxed the restriction on not allowing combinators in :matches() and :not(),
then you could do this:

article.product header:not(article.reviews *) {
   ...
}

That reads as "a header that is a descendant of article.product but is not
a descendant of article.reviews". It would also solve your <p> problem.

article.product p:not(article.reviews p) {
   ...
}

~fantasai

Received on Tuesday, 15 November 2011 23:50:12 UTC