Re: [csswg-drafts] Questions: about relative selectors.. (#10856)

The anchor elements are the other part of your selectors.

https://drafts.csswg.org/selectors/#overview

  > The following table summarizes the Selector syntax:
  >
  > | Pattern              | Represents |
  > | -------------------- | - |
  > | `E:has(rs1, rs2, …)` | an `E` element, if there exists an element that matches either of the relative selectors `rs1` or `rs2`, when evaluated with `E` as the anchor elements |

`*` (universal selector) is implied before a pseudo-selector, like in `:has(+ div#topic > #reference)`, in which it is the (implicit) anchor element.

https://drafts.csswg.org/selectors/#relative

  > Relative selectors begin with a combinator, with a selector representing the anchor element implied at the start of the selector. (If no combinator is present, the descendant combinator is implied.)

A relative selector can currently only appear in `:has()` or as the selector of a [nested style rule](https://drafts.csswg.org/css-nesting-1/#nesting).

For what is worth, I prefer learning CSS by reading the specs rather than MDN, which is still great for a quick overview/refresher.

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


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

Received on Monday, 9 September 2024 19:40:06 UTC