title: Detect support for background-size: cover
body: <p>What is a save way to detect support for CSS3 <em>background-size: cover</em>, especially in IE &lt; 9?  </p>
  
  <p>Following test returns a false positive in IE &lt; 9, because it actually sets <em>background-size</em> to <em>cover</em>:</p>
  
  <pre><code>div.style.backgroundSize = 'cover';
  </code></pre>
  
  <p>The only true result I get when testing for:</p>
  
  <pre><code>if ('backgroundSize' in div.style)
  </code></pre>
  
  <p>But according to the site <a href="http://www.standardista.com/css3/css3-background-properties/#bg11" rel="noreferrer">http://www.standardista.com/css3/css3-background-properties/#bg11</a>, IE 6/7/8 should return <em>auto</em>, only <em>cover</em> and <em>contain</em> are not supported.</p>
  
  <p><strong>Edit:</strong> </p>
  
  <p>I would like to use my own solution, but I have checked the <a href="https://github.com/Modernizr/Modernizr/blob/master/feature-detects/css-backgroundsizecover.js" rel="noreferrer">code used by Modernizr</a>.
  It seems they use the same technique that gives me false positive results in IE &lt; 9:
  Set <em>backgroundSize = 'cover'</em> and then check for <em>style.backgroundSize == 'cover'</em>.</p>
  
  <p>See my <a href="http://jsfiddle.net/cx6DP/1/" rel="noreferrer">JSFiddle</a>.</p>