[csswg-drafts] [selectors-4] Add a count to :has()

srambach has just created a new issue for https://github.com/w3c/csswg-drafts:

== [selectors-4] Add a count to :has() ==
The relational pseudo-class `:has()` is proposed to take a relative selector list as an argument. [https://drafts.csswg.org/selectors-4/#relational](https://drafts.csswg.org/selectors-4/#relational) 

It would be very useful to be able to know how many children (and/or children of a type) the element has. For example, you may want to style a menu differently if it has more than n elements.

Currently, you can use a combination of :nth-last-child, and :first-child to determine at the child level how many siblings there are. (described very well in [https://css-tricks.com/extremely-handy-nth-child-recipes-sass-mixins/](https://css-tricks.com/extremely-handy-nth-child-recipes-sass-mixins/)) 

However, this doesn't allow styling of the parent based on the number of children. Presumably it would be desirable to be able to select based on >, <, or = n children.


Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1547 using your GitHub account

Received on Wednesday, 21 June 2017 15:34:33 UTC