30secondstosam
30secondstosam

Reputation: 4686

Conditional CSS for IE in Wordpress not working

enter code hereI know this has been brought up so many times but I am really struggling to find the answer.

I am currently using the following code:

<!--[if IE 9]>
    <style type="text/css">@import "<?php bloginfo('stylesheet_directory'); ?>/ie.css";</style>
<![endif]-->
<!--[if IE 8]>
    <style type="text/css">@import "<?php bloginfo('stylesheet_directory'); ?>/ie8.css";</style>
<![endif]-->

However, the first stylesheet does not pick up at all and the IE8 one is only picked up in IE9. I really don't know what I'm doing wrong here.

Using strict XHTML. Any help would be massively appreciated.

Oh and also yes, my main reset and other stylesheet is above these. Also I am using Wordpress - this shouldn't make a difference.

EDIT:

Here is some more detail

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-    strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title><?php bloginfo('name'); ?> <?php wp_title(); ?></title>
        <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/reset.css" type="text/css" />
        <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" />
        <!--[if IE 9]>
        <link href="<?php bloginfo('stylesheet_directory'); ?>/ie.css" type="text/css" rel="stylesheet" />
        <![endif]-->
        <!--[if IE 8]>
        <link href="<?php bloginfo('stylesheet_directory'); ?>/ie8.css" type="text/css" rel="stylesheet" />
        <![endif]-->
        <link href='http://fonts.googleapis.com/css?family=Averia+Serif+Libre:400,700' rel='stylesheet' type='text/css' />
        <link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css' />

I then write some JavaScript in the head and call in Jquery. nothing out of the ordinary.

Upvotes: 0

Views: 1240

Answers (1)

Eliran Malka
Eliran Malka

Reputation: 16263

assuming these are located in the document head, try and replace them with:

<!--[if IE 9]>
    <link href="<?php bloginfo('stylesheet_directory'); ?>/ie.css" type="text/css" rel="stylesheet" />
<![endif]-->
<!--[if IE 8]>
    <link href="<?php bloginfo('stylesheet_directory'); ?>/ie8.css" type="text/css" rel="stylesheet" />
<![endif]-->

Upvotes: 1

Related Questions