Re: [csswg-drafts] [css-selectors-4] Selector for element with another element as ancestor (#9130)

Then you should use

```css
.aleph {
  /* ... styles for .aleph ... */
  & .beth {
     /* ... styles for .aleph .beth ... */
    & .gimel {
      /* ... styles for .aleph .beth .gimel ... */
      & .daleth {
        /* ... styles for .aleph .beth .gimel .daleth ... */
        a & { /* or `&:is(a *)` works too */
        /* special styles for .daleth when within a link, regardless of where the a
           is in the tree of .aleph .beth .gimel */
        } } } } }
```

Note that `a &` only requires `a` to be an ancestor of the element matched by the parent selector, basically it will behave like `a :is(.aleph .beth .gimel .daleth)`.

Unlike `a .aleph .beth .gimel .daleth`, `a &` doesn't require `a` to be an ancestor of `.aleph`.

-- 
GitHub Notification of comment by Loirooriol
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9130#issuecomment-1662040049 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 2 August 2023 11:30:16 UTC