Support » Fixing WordPress » IE conditional stylesheet not working

  • Resolved sparkletack

    (@sparkletack)


    I just want to call a CSS stylesheet for IE6 using conditional statements. I’ve read 100 posts on this subject, but it is just not working for me!

    I’ve seen two methods described in these forums, but neither one is calling the IE6 stylesheet.

    (I’ve been placing this code in my header.php file):

    OPTION ONE:
    —————

    <style type=”text/css” media=”screen”>
    @import url( <?php bloginfo(‘stylesheet_url’); ?> );
    </style>

    <!–[if IE 6]>
    <style type=”text/css”>
    @import “http://www.calyxdesign.com/wordpress/wp-content/themes/modern/ie6.css”;
    </style>
    <![endif]–>

    OPTION TWO:
    —————

    <link href=”http://www.calyxdesign.com/wordpress/wp-content/themes/modern/style.css” rel=”stylesheet” type=”text/css” />

    <!–[if IE 6]>
    <link href=”http://www.calyxdesign.com/wordpress/wp-content/themes/modern/ie6.css” rel=”stylesheet” type=”text/css” />
    <![endif]–>

    OPTION THREE
    —————

    <link rel=”stylesheet” href=”<?php bloginfo(‘stylesheet_url’); ?>” type=”text/css” media=”screen” />

    <!–[if IE 6]>
    <link href=”<?php echo bloginfo(‘template_directory’); ?>/ie6.css” rel=”stylesheet” type=”text/css” />
    <![endif]–>

Viewing 9 replies - 1 through 9 (of 9 total)
  • You wouldn’t happen to be testing this on a windows machine with IE 6 and IE 7 installed would you? If so, then a bug related to conditional comments will take over and treat all conditional comments as though the browser is IE 7. So if you’re trying to load the conditional comments in IE 6 or below, it simply will not work for you. You must find a computer that has only IE 6 installed in order to give it a proper test.

    Not sure if this will help you, otherwise all of your code looks good, the third option being the cleanest solution for WordPress.

    Interesting …

    I’m using browsershots.com to test, so it’s a virtual setup for me.

    I’ll see if I can figure out if they have a machine with just IE6 installed.

    Thanks!

    I found a machine that only has IE 6 installed, and the conditional comments still do not show up.

    What’s bizarre is this: I changed my conditional statement to point to IE 7, and it works like a charm! <!–[if IE 7]>

    What the !!???

    Okay, I’ll mark this resolved … it does seem to work in the majority of cases, but let me just curse the name of Microsoft here. Curses!

    You wouldn’t happen to be testing this on a windows machine with IE 6 and IE 7 installed would you? If so, then a bug related to conditional comments will take over and treat all conditional comments as though the browser is IE 7. So if you’re trying to load the conditional comments in IE 6 or below, it simply will not work for you. You must find a computer that has only IE 6 installed in order to give it a proper test.

    wish i saw that earlier, thanks

    shylaz

    (@shylaz)

    Same issue here. Can someone please help?
    My website: http://www.hookahclub.org

    Code that I use:

    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    <!--[if IE 7]>
    <link href="<?php echo bloginfo('template_directory'); ?>/style-ie.css" type="text/css" />
    <![endif]-->

    I also tried using [if IE] syntax, without much sucess. As sparkletack, I also tried all the 3 options, but I simply can’t force IE to read the style-ie.css .

    Any help is appreciated!

    If it needs to be < IE7, use: <!--[if lt IE 7]>
    if it should be IE only, use: <!--[if IE]>

    If that doesn’t work, the css classes aren’t overwritten (could be a CSS issue, but could also be a CSS issue).

    @sparkletack: using <!--[if IE 7]> won’t work in IE6. That’s because the statements says ‘if it is Internet Explorer, and the version is 7’. So, v6 will be left out.

    MS has a virtual machine (for free) and you can download a winxp image with IE6 (also for free) at the Microsoft website. Using it myself for testing purposes like this (only annyoing point – besides the fact is MS, ofcourse – is that the image will expire.. the current one in January 2009).

    Thanks, illutic for the fast reply. Unfortunetely, it doesn’t help either. There’s sure a css issue somewhere, but can’t figure out why IE uses the “master” stylesheet.

    Then the fault is not in the conditional tags, but in the css somewhere.
    OR your IE6 perhaps thinks it’s IE7 (dunno how you’re testing it).

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘IE conditional stylesheet not working’ is closed to new replies.