Search code examples
cssinternet-explorerconditional-comments

CSS for IE 8 Only


I need to style some items for only IE 8. If I do this:

<!--[if IE 8]><link rel="stylesheet" href="mystyleIE8.css" type="text/css" media="screen, projection"/><![endif]-->

and then I do:

<!--[if IE 7]><link rel="stylesheet" href="myStyleIE7.css" type="text/css" media="screen, projection"/><![endif]-->

What will happen? I found this link to a previous SO question which implied that <!--[if IE 8]> means "If IE 8 or lower". Does this mean that using <!--[if IE 8]> will overwrite all <!--[if IE 7]> css? Will my program know to use <!--[if IE 8]> for only IE 8 and <!--[if IE 7]> for IE 7?


Solution

  • It does not mean "If IE 8 or lower".

    <!--[if IE 8]>
    

    Means if it is IE8

    <!--[if lt IE 8]>
    

    If it is less than IE 8

    <!--[if lte IE 8]>
    

    If it is less than or equal to IE 8