CSS attribute selector for non-empty attributes

MR.ABC picture MR.ABC · Jun 22, 2013 · Viewed 46.9k times · Source

Is there a CSS selector that applies to non-empty attributes? Using :not([Data-Attribute='']) matches if the attribute is non-existing, too.

I'm looking for something like [Data-Attribute!=''].

Answer

sangram parmar picture sangram parmar · Jun 22, 2013

try this

<style>
    [Data-Attribute]:not([Data-Attribute=""])
    {
        background-color: Red;
    }
</style>