Is it possible for CSS to select an element based on an inline style property the element has?
For example, if I have this HTML:
<div style="color: red;"></div>
would there be a selector like, say, this:
div[style="colour: red"]
Is it possible for CSS to select an element based on an inline style property the element has?
For example, if I have this HTML:
<div style="color: red;"></div>
would there be a selector like, say, this:
div[style="colour: red"]
2
Answers
No, CSS cannot select elements based on inline styles or specific style properties directly. CSS selectors are limited to selecting elements based on attributes, classes, IDs, and pseudo-classes, but not on the content of the style attribute.
No, selecting an element based on its inline style property directly isn’t supported.
Additionally, if you’re already applying styles inline, there might be no need to reselect the element in internal or external CSS files.