14

I am using selector to select all elements not having one class:

.list th:not(.foo) {
  /* some rules */
}

How can I apply this to more than one class?

.list th:not(.foo), .list th:not(.bar) {
  /* some rules */
}

The CSS above will not of course do that, I need something like this pseudo:

.list th:not(.foo and .bar)

Is it possible in CSS and how?

Legionar
  • 7,472
  • 2
  • 41
  • 70
  • 4 votes for this question ? first of all it's a duplicate of http://stackoverflow.com/questions/5684160/can-i-have-multiple-not-selectors second of all it's a question to which the answer can be found veeeery easily on google or even here on stackoverflow . – Mihai T Sep 30 '16 at 13:52
  • 1
    And? I was searching a lot and nothing has been found – Legionar Sep 30 '16 at 13:53
  • my question was not about multiple not selectors, that is the answer, which I didn't know – Legionar Sep 30 '16 at 13:55
  • 1
    here on SO are thousands of duplicate questions with 100 and more votes... whats your problem, man? – Legionar Sep 30 '16 at 13:56
  • :) well. you need to know how to search : " css :not multiple class " something like this. it's not that complicated. another SO question that has been marked as duplicate of the one i gave you earlier : http://stackoverflow.com/questions/24266518/multiple-classes-inside-not ....... i don't have a problem . i am just saying that posting a question that has been asked so many times and which is sooo easy to find the answer to , should be avoided and surely should not be awarded upvotes – Mihai T Sep 30 '16 at 13:56
  • ok, but I can't upvote it :-) and who upvoted, I don't think so, they will read these comments – Legionar Sep 30 '16 at 14:00

4 Answers4

13

You can use as many :not() selectors as you like.

:not(.foo):not(.bar)
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
2

With upcoming CSS4 selectors you can use a syntax like:

:not(.class1, .class2, .class3)

and so on. But browser support isn't good so far. To be able to use it today, you can use cssnext for example.

Legionar
  • 7,472
  • 2
  • 41
  • 70
Christoph
  • 1,631
  • 8
  • 19
1
.list th:not[class*="class"] { }

It will work with all classes, like class1, class2 etc.

Laurel
  • 5,965
  • 14
  • 31
  • 57
Shahzaib
  • 57
  • 4
0

Use comma to separate class name can get you want

.list th:not(.class1, .class2)
velen
  • 164
  • 1
  • 4