PDA

View Full Version : How to change stylesheets for browsers?



winterdude
05-07-2007, 10:38 PM
Hi.

I'm looking for a way to change CSS sheets depending on the browser the user is on (IE or Other). I can not use and scripts as this template will be submitted to OSWD.org and that is prohibited.

felgall
05-07-2007, 10:58 PM
<link rel="stylesheet" type="text/css" href="main.css">
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="ie.css">
<![endif]-->

winterdude
05-07-2007, 11:15 PM
That doesn't do anything :confused:

rmedek
05-07-2007, 11:23 PM
He's using conditional comments. All browsers load main.css. If the browser is IE, it loads ie.css. Other browsers ignore conditional comments.

winterdude
05-07-2007, 11:35 PM
Yes, I understand that. But when loading the page in IE (mac version) it doesn't show. But if I just put the edited CSS as the main template it shows with the fixes when loaded. Is it just because I'm testing with the Mac version?

nolvorite
05-07-2007, 11:56 PM
<link rel="stylesheet" type="text/css" href="main.css">
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="ie.css">
<![endif]-->

only works on windows.

winterdude
05-08-2007, 12:18 AM
OK. That's fine Microsoft no longer supports IE for mac anyways :)

BWiz
05-08-2007, 02:08 AM
There are several methods to do this; I would mainly suggest JavaScript for this, or possibly a server side language such as PHP. Although it will be slightly more complicated to manage and create, it is certainly more universal than some other methods.