How do i add the style where when people print the page, i can change the background color and font and stuff. how do id add that to an external css?

3 answers

5
points
This was chosen as the best answer

It's pretty simple, just add this somewhere in your head tags...

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

where print.css is your external stylesheet containing styles solely for the printed version.

Answered over 7 years ago by Stuart Memo
7
points

If you want to save making an extra HTTP request, just add this block to the bottom of your normal css stylesheet:

 @media print {

    /* Rules for print here */

 }
Answered over 7 years ago by Shaun Robinson
2
points

You can also add the following line into your master css file;

@import "print.css";

And in your print.css, open the document with

@media print { 

This keeps your print.css separate to your main css rules, and the file itself.

Answered over 7 years ago by Russell Bishop