csscss-selectors

Is it possible to have a CSS selector based on a CSS property (and its value)?


For example, I want a CSS selector for all div elements which have a CSS overflow:auto; property. Is it possible to have a selector of that kind?


Solution

  • No. There's no way to do this with css. You need to use scripting language.

    But if you have defined style in your html like the following then this would be possible like:

    div[style="overflow:auto;"]{
      background-color: #f00;
    }
        <div style="overflow:auto;">overflow is auto</div>