-1

I have used :not() in several sites presuming as with other css3 selectors that cross-device / browser support would be good.

When looking on caniuse - http://caniuse.com/#search=%3Anot() the table suggests that only safari browsers support this selector

Whereas w3schools say differently - http://www.w3schools.com/cssref/sel_not.asp

Can anyone shine any light om this? Ive used the selector heavily over the past few years and want to make sure i should continue to do so!

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Dancer
  • 17,035
  • 38
  • 129
  • 206
  • 2
    http://caniuse.com/#feat=css-sel3 you mean this – Andrew Bone May 13 '16 at 13:11
  • It says for the first result: "Selectors Level 4 allows the :not() pseudo-class **to accept a list of selectors**, which the element must not match any of. **Selectors Level 3 only allowed :not() to accept a single simple selector.** Thus, :not(a):not(.b):not([c]) can instead be written as :not(a, .b, [c])" – Vucko May 13 '16 at 13:14

3 Answers3

3

Since you did a search, you were presented with 3 results that matched your query. The first result is the selector list argument of :not() which, I presume, is what you were looking at. Obviously, this isn't the css selector that you were looking for.

So yes, you can safely keep using :not(). Here's the correct canIuse link for css selectors.

Chris
  • 57,622
  • 19
  • 111
  • 137
  • 1
    See also: [:not selector not behaving the same between Safari and Chrome/Firefox](http://stackoverflow.com/questions/35993727/not-selector-not-behaving-the-same-between-safari-and-chrome-firefox) – BoltClock May 13 '16 at 13:20
  • @BoltClock interesting, thanks! – Chris May 13 '16 at 13:27
3

The one that is safari only says

Selectors Level 4 allows the :not() pseudo-class to accept a list of selectors, which the element must not match any of. Selectors Level 3 only allowed :not() to accept a single simple selector. Thus, :not(a):not(.b):not([c]) can instead be written as :not(a, .b, [c])

Which means this form :not(a, .b, [c]) can be used oppose to this form :not(a):not(.b):not([c]) but only within safari

http://caniuse.com/#feat=css-sel3 tells us

Advanced element selection using selectors including: [foo^="bar"], [foo$="bar"], [foo*="bar"], :root, :nth-child(), :nth-last-child(), nth-of-type, nth-last-of-type(), :last-child, :first-of-type, :last-of-type, :only-child, :only-of-type, :empty, :target, :enabled, :disabled, :checked, :not(), ~ (general sibling)

Which means we can use all of those selectors including :not() in any browser, well all major and updated browsers.

hope that clears it up.

dippas
  • 58,591
  • 15
  • 114
  • 126
Andrew Bone
  • 7,092
  • 2
  • 18
  • 33
1

click

:not() is okay to use ! You looked at the wrong one

johndeer
  • 41
  • 8