CSS media type for all except print

Hello,

I understand that there are 7+ media types for CSS.

I want a special stylesheet for print but all other media should use the same stylesheet.

<style type="text/css" media="print">@import "print.css";</style>
<style type="text/css" media="all except print">@import "main.css";</style>
LVL 16
hankknightAsked:
Who is Participating?
 
R7AFCommented:
You have the following options. You should call the print css after the default one. Then the print.css will overrule the css-rules in main.css. Still, this could mean you have to undo many rules that are screen-specific. To avoid this you could create a third stylesheet, default.css (first in the list!). This has rules for all media. Then you have screen.css for screen specific rules, and print.css for print.
0
 
R7AFCommented:
I think (but am not 100% sure) that leaving out the media attribute will do what you want.

<style type="text/css" media="print">@import "print.css";</style>
<style type="text/css" >@import "main.css";</style>
0
 
hankknightAuthor Commented:
Thanks for the idea R7AF but no, your idea loads BOTH style sheets for the print version.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.