Search code examples
csscss-content

How to make CSS NOT do something


is it possible to make css NOT do something?

example:

ol {
    counter-reset: item;
}

ol.someClassname {
    NOT counter-reset: item;
}

I KNOW that you should just switch the classes to make it work. It's not really an issue, I was just wondering if it could work, thanks


Solution

  • According to the CSS specifications

    The :not pseudo-class represents an element that is not represented by its argument.

    So in your example, this:

    ol {
      counter-reset: item;
    }
    
    ol.someClassname {
      NOT counter-reset: item;
    }
    

    Becomes this:

    ol:not(.someClassName) {
      counter-reset: item;
    }