:not() in CSS explained with example


CSS: not(A) Selector is a pseudo-class is a functional notation taking a simple selector 'A' as an argument. It matches an element that is not represented by the argument. 'A' must not contain another negation selector.

Note 1: IE8 and older don't support :not()

Note 2: :not() only takes a simple selector that means it can not contain nested selectors like :not(section .someclass)

CSS: not() Selector  Syntax

    :not(selector) {
        //CSS Property

Simple Example

Select all div elements without the class .default

Complex Example

Select all div elements which aren't children of another div

Recommend Post


Post a Comment