“Not equal” css attribute selector

Let’s take the example of having to select all the div with the data-lang attribute different from “it”:

div:not([data-lang=it]) {
    // Your CSS here.
} 

If you want to select elements that have an attribute that is set to an empty string, you should use:

div[data-lang]:not([data-lang='']) {
    // Your CSS here.
} 

Leave a Comment

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