...

View Full Version : Browser dependent stylesheet



graficus
09-28-2006, 08:41 PM
Internet Explorer keeps mucking up all the neat CSS that works fine in Firefox and Opera.
Could someone suggest a script that would do something like this:



if browser IE then
response.write
<link rel="stylesheet" type="text/css" href="IE.css">
else
response.write
<link rel="stylesheet" type="text/css" href="normal.css">

ASP only please, no javascript
Thank you in advance!

felgall
09-28-2006, 08:50 PM
IE provides a way to do it in HTML, no scripting of any sort required.



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

graficus
09-28-2006, 09:19 PM
Fantastic! And I thought I knew all the HTML there is to know :)

Thanks!

felgall
09-28-2006, 11:11 PM
It is an IE proprietary way of adding conditional statements into HTML. All other browsers just treat it as comments.

graficus
09-28-2006, 11:28 PM
Are there any other "proprietary" tricks out there?

quackor
09-29-2006, 12:19 AM
Here's what I use to deal with the dreaded 3px bug in IE

#somecss {
margin-left = 0px;
}

*html #somecss {
margin-left = -3px;
}

Every browser but IE will use "#somecss" style properties, but IE will use the ones from "*html #somecss" :)

felgall
09-29-2006, 02:32 AM
Using two separate stylesheets and IE conditionals in the HTML you don't need to use hacks like that, you just put the IE code in the IE stylesheet to override the standard code.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum