I know for standard html attributes there are CSS selectors:
span[class="example"]
But I would like to know if there are selectors for CSS attributes, e.g.
span[background-image].
?
Update:
After reading some of the comments and answers so far, I better give a reason for this “strange” need. I would like to find all elements that have background-image set to anything other than undefined/empty, to apply style to them. The assumption is that I cannot control the existing inline/global styles, only add my own global style sheet.
No.
It would be too expensive a rule for the browser to look up. As you are most likely setting the background-image in other css classes, it would be fairly straightforward to target them explicitly (also, not by using span[class=”example”] but span.example instead)
Also, as you noted in the comments to another answer, rules of the type
would only apply to inline styles, and you’re in for a nightmare if you’re looking them up by value like so
Is the background set explicitly or through a shorthand property like background:#fff url(potato.png); Did I enter a space there or not? Capitalization, maybe it’s .PNG?