Support » Themes and Templates » Alternate stylesheet for IE

  • I have been seriously vexed by this. I have tried using the javascript conditional tags in my header.php to get IE to use a second stylesheet I made, but it doesn’t work. I also have tried using a php solution I found here in the threads, but can’t get it to work either. I t has to be something I’m doing wrong, if other people have implemented both approaches successfully.

    Could someone explain to me charactor for charactor what to write and on what line in my header.php to put. Please. I have spent two days trying to figure this out.
    I’m have WP, IE6 SP2, and Firefox.


Viewing 13 replies - 1 through 13 (of 13 total)
  • If I understand you correctly, you’re looking to add a stylesheet JUST for IE. If you are, you can do so by adding this in your header:

    <!–[if IE]>
    <link rel=”stylesheet” type=”text/css” href=”iespecific.css” />

    I have added this to my header.php already. In notpad++ it appears in green, ju st like when I add comments into my files. Why it appears this way I don’t know. Do I need to add some sort of opening and closing tags for this?, like <script> and </script>?

    UPDATE: tried adding the opening and closing tags – it had no effect.

    What could keep this from working? I have even placed an absolute path to the file, and tried placing it in various locations around the header file.

    Moderator James Huff


    Volunteer Moderator 🚀

    Try this:

    <?php if (eregi("MSIE",getenv("HTTP_USER_AGENT")) ||
    eregi("Internet Explorer",getenv("HTTP_USER_AGENT"))) { ?><link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_directory'); ?>/style-ie.css"/>
    <?php } else { ?>

    <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_directory'); ?>/style.css"/>

    <?php } ?>

    i tried this and it isn’t working. Where it says “style-ie.css” in your suggested script above i put the name of my ie file. This would be correct, right?
    I also have tried the javascript mentioned above. Something is keeping it from working. Whatever it is, it is keeping everything from working – javascript or php.

    I have pasted my header.php at this site:

    Kubrick default theme WP1.5.1.3

    If anybody else has any input it would also be appreciated. Thanks!

    Is this second stylesheet for the theme that’s visible now on your blog? As far as I can see it’s a default K. theme with a changed header image. The Default theme works perfectly across browsers.

    First, sorry it took so long to return a response to my own thread.
    Yes, it is the Kubrick default theme. But, the nav bar I built renders well in Firefox, but not IE. Now, being new to CSS, it is still out of my reach to juggle CSS in one file for two browsers. What I hoped to do was create an exact copy of my primary stylesheet that only IE would use. I could then more easily tweak until it renders things correctly in IE, without screwing up anything in other browsers. For some reason, I can’t get the javascript tags to work. When I open the header.php in Notepad++, these tags appear in green, as if they are commented out. Just like actual comments appear. I have checked permissions on files, etc..
    Any help most appreciated. My header.php can still be found at the link in the above post.

    Ok, I checked the link above. Not there anymore. must have a time limit. My eader.php has been resubmitted here.

    Thanks for any help on this!

    I too was having the same problem, needed a IE specific stylesheet and the code I was using was also comming up as a comment in Notepad++. I tried many things but I got it to work by using macmanx’s code. The only alteration I made to my own code was to delete the line “<link rel=”stylesheet” href=”<?php bloginfo(‘stylesheet_url’); ?>” type=”text/css” media=”screen” />” because it is already in the code.
    So then I pasted macmanx’s code in its place and what do you know it worked.
    Thanks a lot macmanx!

    You have it worked but i want to say tha i also preffer
    “jdingman” way but you must use it like this:

    <!--[if IE]>
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/IE.css" type="text/css" media="screen" />

    have fun.

    macmanx … thanks! That’s exactly what I needed and it works perfectly — as far as I can tell, using Firefox 1.0.6, Opera 8.5 and IE6 on WinXP Pro.

    macmanx, you saved me once again. I’ve been working on a new theme that I created from scratch and silly IE was screwing up my alignment … now I can have an altered view for my IE visitors (the poor souls, lol).

    Thank you!!! 🙂

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Alternate stylesheet for IE’ is closed to new replies.