Search code examples
htmlinternet-explorerstylesheetconditional-comments

Does ie read stylesheets outside of conditional comments?


I've been doing a bit of reading around this subject, and I can't seem to find an answer that specifically answers this question.

Using this code as an example:

<!--[if lte IE 7]>
    <link rel="stylesheet" type="text/css" href="ie-style.css" />
<![endif]-->
<link rel="stylesheet" type="text/css" href="style.css" />

Would IE6 open and run it-style.css and style.css, and if not, why not? Also, does the order in which you place conditional and non-conditional stylesheets matter?


Solution

  • Yes it will open both.

    Whatever style sheet is placed last has higher priority.

    If this attribute was in ie-style.css

    body {
        background:#000000; //black
    }
    

    and this attribute was in style.css

    body {
        background:#FF0000; //red
    }
    

    and this is what the order of style sheets were in your <head>

    <!--[if lte IE 7]>
        <link rel="stylesheet" type="text/css" href="ie-style.css" />
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="style.css" />
    

    then the body will be red even if you were on IE.