Skip to content Skip to sidebar Skip to footer

Css Conditional Comments For Other Browsers Except Ie?

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, w

Solution 1:

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"type="text/css" />

<![endif]>

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

Solution 2:

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?

Solution 3:

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).

Solution 4:

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.

Solution 5:

As noted in other answers there are no conditional comments for browsers other than IE. Using JS detection is the way to go here.

If you want to have the commented element affect the IE condition AND other browsers then simply do this:

<!--[if gt IE 8]><!--><linkhref="sample.css"rel="stylesheet"type="text/css" /><!--><![endif]-->

As you can see from the syntax highlighting the link element is not commented out so it will be visible for non-IE browsers and for IE it will follow the condition (greater than IE 8 in this example).

Post a Comment for "Css Conditional Comments For Other Browsers Except Ie?"