Here\'s the CSS , and I want the background picture not to be displayed in IE . Instead I just want the background color to be displayed. How do I do that?
h
There is obviously multiple ways to answer this question, some good methods already mentioned. Here is another method that I use most often and it requires less bytes:
To target only Internet Explorer, put an "*" in front of the code that you want to target for I.E. Using your example above, for the background to not appear in I.E. use the * like so:
html, body {
margin:0;
padding: 0;
background: #a9ac41;
*background-image: none;
background-image: url("background.png");
background-repeat: no-repeat;
background-size: cover;
margin:0;
If and when it doesn't work, likely your rules are conflicting. In such cases, use "!important", like so:
*background-image: none !important;
replace the tag html
of your HTML for this:
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
then in the css:
html,body{
margin:0;
padding: 0;
background-image: url("background.png");
background-repeat: no-repeat;
background-size: cover;
margin:0;
padding: 0;
}
html.lt-ie9,html.lt-ie9 body{
background: #a9ac41;
background-image: none;
}
Note: IE10 doesn't support conditional comments son this method works in < IE9.