WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] IE conditional stylesheet not working (10 posts)

  1. sparkletack
    Member
    Posted 6 years ago #

    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]-->

  2. robc
    Member
    Posted 6 years ago #

    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.

  3. sparkletack
    Member
    Posted 6 years ago #

    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!

  4. sparkletack
    Member
    Posted 6 years ago #

    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 !!???

  5. sparkletack
    Member
    Posted 6 years ago #

    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!

  6. pabmtl
    Member
    Posted 5 years ago #

    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

  7. shylaz
    Member
    Posted 5 years ago #

    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!

  8. Hiranthi
    Member
    Posted 5 years ago #

    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).

  9. shylaz
    Member
    Posted 5 years ago #

    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.

  10. Hiranthi
    Member
    Posted 5 years ago #

    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).

Topic Closed

This topic has been closed to new replies.

About this Topic