Code.Useful snippets for WordPress.

Add web browser type class to the body tag of your WordPress theme

Often you run into CSS issues with different browsers, and one way to easily make browser-specific CSS is if you have a browser class added to the body tag of your theme. That way you can for example just add .ie8 .myclass { cssfix } to specify CSS that will only be read by a certain browser (IE8 in this case).

3 Responses

This is actually really helpful, thank you. But, I’ve tried it on opera (latest 20.0) and it actually adds “chrome” instead of the “opera” class, any ideas? Safari on the other hand only works if I disable the W3 total caching.

Works fine on Firefox (changed gecko to ff), as well as chrome. You can check my site if you want to see it live, thanks again.