Selector for style

I know attribute selectors e.g. input[name].

Is there something similar for style attributes like div[style|float]?

Yes and no. :rofl:

  1. Yes, div[style="float-right"] {} will work in theory. :wonky:
  2. No, inline styling is very poor coding methodology and should
    really be avoided like the plague. :unhappy:

Further reading:-

  1. MDN - The CSS attribute selector
  2. Avoid Inline CSS


  1. Sorry, but not. Works div[style*=float], but this is not really optimal I think.

  2. Sure. But point is: inline-style couldn’t be overrided with another class somewhere in code. And sometimes that is required.

The fact you are asking this question rings alarm bells.

The only way to override in-line styles in CSS is with !important, which is yet further down a slippery slope, that you climb down at your peril.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.