CSS media type for all except print


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
Who is Participating?
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.
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>
hankknightAuthor Commented:
Thanks for the idea R7AF but no, your idea loads BOTH style sheets for the print version.
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.