Log in

View Full Version : Css conditionals



d-machine
09-08-2009, 10:14 AM
Hi,

I have a css file, and I want to have seperate style fore different browsers, like this:

if (opera)
color:red;
if (firefox)
color:black;
if (IE)
color: white;
else
color: green;
How can I do it?

codeexploiter
09-08-2009, 10:40 AM
You'll have to go for the browser specific CSS hacks if you are looking for a CSS only solution. But using CSS hacks is not a good method though the developers use it to troubleshoot some issues in some specific browsers, mostly in IE.

In most of the browsers these kind of CSS hacks can be done. Also most kind of CSS hacks works in a cross-browser manner. Some of the CSS hacks used in Firefox will work correctly in Google Chrome, Apple Safari, etc. Some does not. It will really difficult to identify the unique CSS hack for different browsers.

But the operations that you've mentioned can be done through JS without much trouble though.