Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    May 2007
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to change stylesheets for browsers?

    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.

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    <link rel="stylesheet" type="text/css" href="main.css">
    <!--[if IE]>
    <link rel="stylesheet" type="text/css" href="ie.css">
    <![endif]-->
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    New Coder
    Join Date
    May 2007
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That doesn't do anything

  • #4
    Senior Coder
    Join Date
    Nov 2003
    Location
    Minneapolis, MN
    Posts
    2,879
    Thanks
    2
    Thanked 65 Times in 56 Posts
    He's using conditional comments. All browsers load main.css. If the browser is IE, it loads ie.css. Other browsers ignore conditional comments.

  • #5
    New Coder
    Join Date
    May 2007
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #6
    Regular Coder
    Join Date
    Dec 2006
    Posts
    177
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by felgall View Post
    <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.

  • #7
    New Coder
    Join Date
    May 2007
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK. That's fine Microsoft no longer supports IE for mac anyways

  • #8
    Regular Coder BWiz's Avatar
    Join Date
    Mar 2006
    Location
    Sol System
    Posts
    471
    Thanks
    7
    Thanked 21 Times in 21 Posts
    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.
    BWiz :: Happy Coding!
    2006
    2007 2008 2009
    2010 2011
    Irrational numbers make no sense.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •