Frexuz
Frexuz

Reputation: 4933

CSS attribute selector in IE7 - Contains substring on the style attribute

I would like to select an element on its style element. For example, my current WYSIWYG editor puts style attributes to align images, like so:

<img src="my_image.png" style="align: left;" />

Selectors I've tried:

img[style*='align: left']
img[style*='align:left']
img[style*='eft']

All these work fine in all browsers except IE7.

Upvotes: 0

Views: 664

Answers (2)

ScottS
ScottS

Reputation: 72261

Doing a bit of research online yielded the fact that IE7 does not recognize (even CSS2) attribute selection for the style element.

If there is a way to configure your WYSIWYG to apply a class to those elements being aligned (and perhaps doing the alignment by that), then IE7 will recognize img[class~=yourClassName] as an attribute selector. But then, it is quite likely you would just apply your style through the class itself: img.yourClassName and skip the whole attribute selection.

Otherwise, use javascript.

Upvotes: 0

Fabrizio Calderan
Fabrizio Calderan

Reputation: 123397

I think it's not possible: according to sitepoint

In Internet Explorer 7: The style attribute can't be used in attribute selectors.

so basically the only way to target that element on IE<7 is probably using javascript

Upvotes: 2

Related Questions