W3C home > Mailing lists > Public > public-css-archive@w3.org > March 2020

[csswg-drafts] [css-selectors] has-child selector (#4903)

From: Chris Harrelson via GitHub <sysbot+gh@w3.org>
Date: Fri, 27 Mar 2020 02:58:34 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-588851901-1585277913-sysbot+gh@w3.org>
chrishtr has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-selectors] has-child selector ==
Proposal: add a selector that matches an element if a direct child matches the selector in the function.

"all a elements that contain an img" -> `a:has-child(img)`

Motivation: [#2 missing-features request](https://2019.stateofcss.com/opinions/#missing-features) in the state-of-CSS 2019 survey.

Since it only matches direct children, it may be no more expensive than sibling selectors.

A related selector that was considered and removed as too expensive and slow (AIUI) is [:has](
https://drafts.csswg.org/selectors-4/#relational). See also resolution regarding it [here](https://github.com/w3c/csswg-drafts/issues/3925#issuecomment-492724267).

@tabatkins @lilles 

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4903 using your GitHub account
Received on Friday, 27 March 2020 02:58:37 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:42:02 UTC