0

In my web page, I'm using 2 stylesheets :

<link rel="stylesheet" href="css/screen-layout.css" media="screen" type="text/css" />
<link rel="stylesheet" href="css/print-layout.css" media="print" type="text/css" />

inside print-layout.css there is :

.ui-dialog * {display: none !important;}

When I viewed my webpage on IE7, it's supposed to ignore the media="print" one, but it didn't, it applied the display: none, causing all the elements to be hidden. And in the debugbar plugin for IE7, I can see that IE7 applied the print-layout.css file. How is that possible? or am I missing any requirements for using print on IE7?

Thanks :)

phnah
  • 1,711
  • 1
  • 15
  • 21
  • 1
    Forget IE7, it's the new IE6. – Kyle May 02 '13 at 08:45
  • 1
    @Kyle Sevenoaks : 'forget it' is the perfect solution, but the client demands it =]]... – phnah May 02 '13 at 09:01
  • 1
    Then why not explain to the client that IE7 is no longer a viable option to suppoort. The time it takes us to support vs the amount of users still using it is waaayy weighted in our favor ;) – Kyle May 02 '13 at 09:05
  • 1
    why is ie7 supposed to ignore that style? – albert May 02 '13 at 09:05
  • 1
    @KyleSevenoaks : :D...haha alber : I want to know why too... – phnah May 02 '13 at 09:14
  • @albert : sorry I misunderstood your comment yesterday. It is supposed to ignore the media="print" stylesheet, because it's for print device only. – phnah May 03 '13 at 01:29

1 Answers1

4

That syntax works even on IE7 but if you need to exclude that browser from applying your print style, just rewrite your last inclusion in this way:

<style type="text/css" rel="stylesheet">
   @import url('css/print-layout.css') print;
</style>

since IE7 hasn't implemented the media type on @import rule.

Otherwise just wrap the second inclusion in a conditional comment, like so

<!--[if (gte IE 8)]><!-->
   <link rel="stylesheet"... media="print" /> 
<!--<![endif]-->

so you include the print style for all browser except IE < 8.


As a side note: IE7 usage is globally < 1%:
see http://gs.statcounter.com/#browser_version-ww-monthly-201211-201304

Fabrizio Calderan
  • 120,726
  • 26
  • 164
  • 177