skip to Main Content

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


  1. 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.

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search