Internet Explorer is to IE as Firefox is to....?

J.B

J.B

Soldato
Joined
16 Aug 2006
Posts
5,924
this might be a dumb question but....
if i use the statement:
Code:
 <!--[if IE 6]>
  <link rel="stylesheet" type="text/css" href="menu.css" />
<![endif]-->

to detect IE6 and a similiar on to detect IE7, how do I detect firefox?

Thanks guys
 
you can't. those conditional comments are for IE only :)

edit: what I do is put my decent stylesheet in normally (that caters for Firefox, Opera and largely IE7), then do the conditional comments to import and overwrite rules in the preceding stylsheets. if that makes sense. probably doesn't.
 
That kinda half makes sense. my main stylesheet seems to work on IE7, FF and Opera. Its only for IE 6 i need a new one.

so if i just wrote the link in normally into the head and the

<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="menu.css" />
<![endif]-->

it would work?
 
Yep, but make sure to put that stylesheet for IE6 after your normal stylesheet link so that it overrides the relevant rules (according to the cascade).

Code:
<head>
<title>Page Title</title>

<link rel="stylesheet" type="text/css" href="for-all-browsers.css" />

<!--[if IE 6]>
 <link rel="stylesheet" type="text/css" href="just-for-ie6.css" />
<![endif]-->
</head>
 
!important means that attribute will not be overwritten if it is repeated or another stylesheet attempts to change the value. IE6 ignores this and will happily re-assign a value to anything you mark as important. You can use it like this (as a hack):

Code:
width: 350px !important;
width: 348px;

So then the width in FF, IE7, etc will be 350px, and IE6 will use the 348px value instead...
 
haha - yeah, not sure why I wrote that. My boss even gets distraught when I use them.

I just find it easier to have it in the default stylesheet rather than another one.
Then again, I really only use them for the double margin and comment bugs.
 
Back
Top Bottom