Jump to content

Loading different CSS Sheets for Browsers


londesbb

Recommended Posts

I'm having trouble coding any kind of if statement to load the code appropriately. You can view the website at http://www.londes.com/aa . If you are running IE it will not look right, if you are running Firefox or something else it should be fine. What I want to do is load a different page if the user is running IE.Please let me know how I can do this if possible.

Link to comment
Share on other sites

It doesn't look like that supports ways of loading Firefox, as for some reason the ! operator isn't doing anything.I tried this and it didn't work:<style><!--[if IE]><link REL="STYLESHEET" TYPE="text/css" HREF="/ie.css" Title="TOCStyle"><![endif]--><![if !IE]><link REL="STYLESHEET" TYPE="text/css" HREF="/firefox.css" Title="TOCStyle"><![endif]></style>Also tried this which did not work:<!--[if IE]><STYLE TYPE="text/css"> @import url("ie.css") </STYLE><![endif]--><![if !IE]><STYLE TYPE="text/css"> @import url("firefox.css") </STYLE><![endif]>

Link to comment
Share on other sites

What you need to do is load the firefox stylesheet first then use the conditional comments to load your IE only stylesheet which only contains css code meant for IE.

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

Link to comment
Share on other sites

By the way, here's a hint. You can load special styles for all browsers, including IE, and then load other styles for everyone, except IE. Here's tre trick:

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

The key is in the non standart <comment> tag supported only by IE. Because the second stylesheet is suppose to be enclosed in it, IE should (I haven't tested this) ignore the stylesheet inside. The best thing about this method is that it validates, scince everything in comments is ignored by the validator.

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