Francisc Francisc - 3 years ago 186
CSS Question

CSS Select Images with style="float:left" possible?

Similar to selecting

can I somehow select images that have a style property of
set to

I want to set left and bottom margins for them which don't apply to right floating images.

Thank you.

Answer Source

Peter W solution needs to be fixed like this: (changed ~= to *= )

img[style*="float:left"] {
  margin: 5px 15px 0px 0px;

img[style*="float:right"] {
  margin: 5px 0px 0px 15px;

The only issue is that it makes an exact match, so float:right will match, while float: right wont (notice the extra space).

I tested successfully in Chrome and IE9, but in IE emulation mode will not work ...

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download