Does jQuery or other JavaScript libraries support CSS4 selectors? Even browsers? How can I test them?

- 88,409
- 26
- 156
- 177

- 3,293
- 2
- 30
- 57
-
5There is no (and will never be) CSS4. That's CSS Selectors Level 4, a CSS3 module. – Oriol Apr 05 '16 at 08:42
-
i think yes, because i have hear about css4 since 1 years ago and still annoying – Ram kumar Sep 05 '17 at 05:43
2 Answers
The only level 4 selectors that jQuery supports at the moment are :has()
and the extended version of :not()
— and that's only because the spec took inspiration from jQuery itself, as jQuery had already implemented them years before the spec had its First Public Working Draft published in 2011.
I wouldn't expect jQuery to implement any of the other features until the spec has stabilized (i.e. reached at least CR). You'll notice that :has()
doesn't appear in the 2013 WD that you link to. That's because the subject selector, that does appear in the 2013 WD, was dropped in favor of :has()
only a little over a year ago.
So you can imagine why vendors are still holding back on implementing the spec. However, since at least one browser now partially implements Selectors 4, hopefully we won't have to wait much longer for other browsers to catch up.
You can easily test them by just using them and seeing if they return the elements you expect.
-
Infact parent selector made me exciting. I have not known has selector. Is it support by all modern browsers? – Kamuran Sönecek Apr 05 '16 at 08:51
-
No, no browser supports it as yet. And even if browsers do support it, it's unlikely you'll be able to use it in CSS. The "parent selector" is just a slightly less powerful and less intuitive version of :has(). And I'm surprised you weren't aware of its existence in jQuery - it's practically one of jQuery's selling points. – BoltClock Apr 05 '16 at 08:53
-
@KamuranSönecek parent selector? .parent() is already there in jquery. Why to worry? – Bhojendra Rauniyar Apr 05 '16 at 08:54
-
-
@BoltClock Yes. There's no selector. But to work I am saying to OP to use them. – Bhojendra Rauniyar Apr 05 '16 at 08:55
-
I know .parent() method but I can't use it in css, In some cases(complex selections) It's not usefull. – Kamuran Sönecek Apr 05 '16 at 09:08
css4 is still in draft. It is not adapted by all browsers. Whatever the browsers support css4 css declarations that will be automatically supported by jquery.

- 83,432
- 35
- 168
- 231
-
4I think the question means if jQuery polyfills some Selectors 4 syntax when browsers don't support it. – Oriol Apr 05 '16 at 08:45