Jump to content

need help with <![if !IE]>


dain

Recommended Posts

Hi. As most of you probably know, its almost impossible to use the same CSS for every browser, so I had to make two, one for Netscape-based browsers, and a second one for IE-based browsers.That isnt too bad, but now I ran into another problem;I'm using this script to redirect the CSS depending on the browser:

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

It works perfectly on both browsers, but its not valid XHTML! So I change it to:

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

And now its perfectly valid, but it wont load ANY CSS in Netscape.What do you think I should do?Thanks, dain

Link to comment
Share on other sites

Well, I can't answer your question, but I can suggest a nice little hack for styles. When you have a style that you want to show up differently in IE, you just preceed it with a *.ex:margin-left: 20px;*margin-left: 22px;firefox will skip the * statement while IE takes the bait. Very handy :)

Link to comment
Share on other sites

  • 1 year later...
Guest FirefoxRocks

Try using this:

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

Link to comment
Share on other sites

Hi dain,Thanks for posting this code......as I was also facing the problem in running my css code on every browser.But now the issue with me is that I am not able to understand how its working.....as the code we are putting as commnmets which the browser shuld ignore.Than how its working???(I am sorry if I ma sounding stupid but I am new in all this).I need ur guide and help...bye

There's also a small article about them here.
Link to comment
Share on other sites

Excuse me all, but... am I the only one that sees how old this topic is? It's so old IE7 beta wasn't out yet. Not to mention the poster hasn't been around since... (checking up)... 12th November 2005.

Link to comment
Share on other sites

Guest FirefoxRocks
Hi dain,Thanks for posting this code......as I was also facing the problem in running my css code on every browser.But now the issue with me is that I am not able to understand how its working.....as the code we are putting as commnmets which the browser shuld ignore.Than how its working???(I am sorry if I ma sounding stupid but I am new in all this).I need ur guide and help...bye
That's the funny thing. Every other browser ignores the stuff except Internet Explorer reads the [if IE] or [if !IE] part. It is a hack around Internet Explorer.
Link to comment
Share on other sites

Excuse me all, but... am I the only one that sees how old this topic is? It's so old IE7 beta wasn't out yet. Not to mention the poster hasn't been around since... (checking up)... 12th November 2005.
Noticed that myself... last night. thought maybe the Database got re-set or some such thing...
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...