CSS media type for all except print

Posted on 2007-10-09
Last Modified: 2008-01-09

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>
Question by:hankknight
    LVL 13

    Expert Comment

    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>
    LVL 16

    Author Comment

    Thanks for the idea R7AF but no, your idea loads BOTH style sheets for the print version.
    LVL 13

    Accepted Solution

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
    Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
    In this Micro Tutorial users will learn how to embed custom fonts into websites using @font-face in CSS Select a font: Ensure the EULA allows you to use @font-face: Download the font: Get the browser-compatible files you need: Edit your CSS       - Name …
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now