- From: Rolf-B via GitHub <sysbot+gh@w3.org>
- Date: Thu, 16 Nov 2023 14:00:00 +0000
- To: public-css-archive@w3.org
Rolf-B has just created a new issue for https://github.com/w3c/csswg-drafts: == Greediness of selectors with combinators [selectors-4] == This is not an issue, but I'd like a clarification. Assume a (dummy) HTML like this: `<a>a1</a> <b>b1-1</b> <b>b1-2</b> <a>a2</a> <b>b2</b> <a>a3</a> <b>b3</b>`. Now, I want the b1 elements to be highlighted when the mouse hovers on a1. But not b2 or b3. And the number of b elements after an a element is variable. I created this css rule pair to achive that: ~~~css a:hover ~ b { background-color:yellow; } a:hover ~ b ~ a ~ b { background-color:inherit; } ~~~ This works, because the second rule matches the first a element behind the a:hover element. My question is: Is this behavior **specified**? Or is it implementation dependent? Because - as in regex patterns, there could be a greedy oder non-greedy matching. The `~ a ~` part of the second selector could match a2 (non-greedy) or a3 (greedy). To be clear: I ask if the non-greediness of combinators is specified, and where. I don't look for better html or css - the problem occurred for me in a more complex situation where changing the markup is not an option. Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9605 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Thursday, 16 November 2023 14:00:02 UTC