0

I want to use gradient for background in Mozilla Firefox Like

 background: -moz-linear-gradient(#C6991D, #F7D065) repeat scroll 0 0 transparent;

And for other browsers i m using background-color Like

 background-color: #DFB542;

I need to put condition only for firefox. I know the condition for IE

 <!--[if IE 6]>
     instructions for IE 6 here
 <![endif]-->

But not for firefox. Plz help me.

Thanks!

Adi
  • 4,766
  • 3
  • 20
  • 22

3 Answers3

2

this does not need conditionals

background-color: #DFB542;
background: -moz-linear-gradient(#C6991D, #F7D065) repeat scroll 0 0 transparent;

since -moz- is a vendor-specific prefix by itself, only firefox reads it. it' ignored by other browsers.

placing it in this order in your CSS, firefox will read the first declaration and then the second will override or cascade over the first.

on other browsers, they read the first declaration but ignore the seconds since they don't know how to parse it. they skip over the second declaration.

Joseph
  • 117,725
  • 30
  • 181
  • 234
0

Firefox doesn't understand conditional comments, only IE does. So Firefox simply skips on <![if !IE 7]and <![endif] as unrecognized tags but it render the rest. It means that you cannot use content- revealing comments here, only content-hiding ones.

See this post

Pankaj Upadhyay
  • 12,966
  • 24
  • 73
  • 104
  • Actually, it's just a comment in any other browser. IE set it up so that in non-IE browsers, the entire thing between the `` would still be enclosed in a comment and would not be rendered by other browsers. Also, please fix your link. – animuson Jan 06 '12 at 08:19
  • I explained this because he wanted to use commenting in HTML for firefox. – Pankaj Upadhyay Jan 06 '12 at 08:29
-2

You can do it with javascript

if(navigator.appCodeName=='Mozilla' || navigator.appCodeName=='Netscape'){
   document.write('<style type="text/css">');

   //document.write('your css code');

   document.wirite('</style>');
}
FURKAN ILGIN
  • 2,290
  • 3
  • 18
  • 21
  • Don't use user-agent detection, that is a relic of the bad old days and is not guaranteed to work. See for example: http://stackoverflow.com/questions/2780652/why-navigator-appcodename-returning-mozilla This is actually a really bad example outside of that fact, injecting CSS code directly to the page with `document.write`? – Wesley Murch Jan 06 '12 at 08:29
  • How can i write javaspript code for Mozilla without user agents detection? – FURKAN ILGIN Jan 06 '12 at 20:41