简体   繁体   中英

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.

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

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM