Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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, what could be the best alternative?

like image 704
Starx Avatar asked Jun 15 '10 07:06

Starx


People also ask

Which is the only browser that supports conditional comments?

Conditional comments are conditional statements interpreted by Microsoft Internet Explorer versions 5 through 9 in HTML source code.

How do you use conditional comments in HTML?

Conditional comments are conditional statements to hide or provide HTML source code from Internet Explorer. 2. There are two types of conditional comments - downlevel-hidden - which is used to hide HTML source and downlevel-revealed which is used to reveal HTML source code in Internet Explorer.

What is if IE in HTML?

--[if IE]> syntax, resolves the if and parses the content of the conditional comment as if it were normal page content. Since conditional comments use the HTML comment structure, they can only be included in HTML files, and not in CSS files.


1 Answers

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.

like image 104
Sarfraz Avatar answered Sep 20 '22 02:09

Sarfraz