Search code examples
cssprintingmedia-queries

Is there a way to use the same CSS stylesheet for print media and the default layout?


I am looking for a way to use the same stylesheet for print media as for the default onscreen layout. The advantage to me will be that I won't have to update 2 files every time I update the CSS. I would prefer to have one stylesheet and specify special rules for print media by denoting them somehow… It may not be possible, but I thought I'd put the question out there.


Solution

  • There's this syntax, although I honestly don't know if it's supported across all browsers (it should be):

    @media print {
        body {
            background: #fff;
            color: #000;
        }
        /* etc */
    }
    

    See the media part of the CSS2 standard at W3.