Re: [css3-selectors]: Proposal: Reverse Descendant selector

Axel Dahmen skrev:
> AFAIK, there is no way to create a selector matching an element whose
> descendant properties match certain criteria. E.g. you cannot apply
> CSS rules to a <div> element provided it's containing an <a> element
> having focus.
>
> I suggest to use the "<" (less than) token for such reverse descendant
> selector:
>
> --------------------
>
> body > div < a:focus
> {
>   border: 1px solid red;
>   background-color: yellow;
> }
>
> --------------------
>
> <body>
>   <div comment="this is where above rules get applied if <a> has focus">
>     <span></span>
>     <a></a>
>     <span></span>
>   </div>
> </body>
>
> --------------------
>
> Your thoughts?
>
> Axel Dahmen
>
>
>
Been there, tried that. First it was proposed using ! to mark the
element to apply the rule to. Now we have it as the ":has" function.
Spoiler: it's not in the fast profile, so it can't be used in stylesheets.

Received on Monday, 19 September 2016 18:16:44 UTC