Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I print a web page with all its css style attached to the page?

I want to add a print button to enable users to print my web page. However when I print all the css styles are lost. It seems the printer only keeps the basic html elements. If I also want to print out the page exactly as it looks like in a browser, what should I do? I mean if I use a color printer it will print a colorful page with css styles on it. When I use a black and white printer it should print light colors as white and dark colors as grey or black.

like image 422
newguy Avatar asked Aug 02 '10 04:08

newguy


2 Answers

If you have media="screen" on your link element, try to remove it or replace with media="all".

like image 97
Daniel O'Hara Avatar answered Nov 15 '22 09:11

Daniel O'Hara


Take a look at this and this, that should help.

Basically you need to add a css print statement.

<link rel="stylesheet" href="URL to your print.css" type="text/css" media="print" />
like image 4
Dan Avatar answered Nov 15 '22 08:11

Dan