views:

111

answers:

4

So far I know, the conditional comments are only supported for different Versions of IE.

Likeways, can we provide conditional comments for other browsers too.

If Yes, How? If no, what could be the best alternative?

+1  A: 

As far as I know, CSS conditional statements are an IE exclusive. They should not be needed for other browser since they follow standards reasonably well. Why would you need them?

kemp
@kemp, I know other browser follow quite same standards but not an exact match.
Starx
@Starx Browsers are different you can use javascript to try and catch these or you just have to understand there are differences between browsers it depends on how much time and effort you are willing to put in.
Thqr
@Starx otherwise you can design your page without styling that causes differences between browsers I mean there are ways around it but not easy or efficient... The CSS browser selector plugin. Is probably one of the easiest ways to do it with script.
Thqr
A: 

Check out the CSS Browser Selector plugin. I use it on my site, you basically just write the CSS and tell which browser you want it to target. I use it on my site and it works great!

Hope it helps.

Kyle Sevenoaks
not quite the answer I am looking for but it will work
Starx
+1  A: 

CSS Conditional Comments are meant only for IE.. However, you can detect Firefox:

If the following code fails to exclusively detect Firefox..

<!--[if !IE]>
  ...statements...
<![endif]-->

Use "Downlevel-revealed Conditional Comments" to get it working...

<![if !IE]>
  ...statements...
<![endif]>

Example to force Firefox to use an exclusive css..

<![if !IE]>

  <link href="css/ff.css" rel="stylesheet" type="text/css" />

<![endif]>

Having said that, you should not be much worried about other browsers which are standard-compliant.

Sarfraz
+1  A: 

There are not conditional comments for other browsers only IE and versions of IE.

You can using Javascript do checks for other browsers and apply styles as follows.

You can do a check for the browser to not be IE with conditional comments but just no.

I would suggest visiting W3.org and building your site to be functional with a standard conforming browser then use the conditional comments to fix up how it loads in IE if there are issues (there usually is).

Thqr