How to fix :not(:empty) CSS selector is not working?

Spread the love

Sometimes, we want to fix :not(:empty) CSS selector is not working.

In this article, we’ll look at how to fix :not(:empty) CSS selector is not working.

How to fix :not(:empty) CSS selector is not working?

To fix :not(:empty) CSS selector is not working, we replace :empty with the value attribute selector.

For instance, we write

input:not([value=""]):not(:focus):invalid {
  background-color: tomato;
}

to select the inputs with value not empty with not([value=""]).

Conclusion

To fix :not(:empty) CSS selector is not working, we replace :empty with the value attribute selector.

Leave a Reply

Your email address will not be published. Required fields are marked *