Mohammad Saberi
Mohammad Saberi

Reputation: 13166

Apply css styling in print paper

I have some reports in HTML format and want print them in my web application. The problem I have is that I can not force printing operation to apply css properties to coloring header and footer.

<td style="background-color:gray">Total</td>

I expect to see a gray background color row in the printed paper, but everything is white as cells background color.

What do I have to do ?

Upvotes: 1

Views: 308

Answers (2)

punkrockbuddyholly
punkrockbuddyholly

Reputation: 9794

Have you tried adding the styles via a media query? Either like this in a <style> block:

@media print {
    td { background-color: gray; }
}

Or like this in a link in the <head>:

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

In case you're not aware of print stylesheets here's a good article on it http://coding.smashingmagazine.com/2011/11/24/how-to-set-up-a-print-style-sheet/

Upvotes: 2

Curtis
Curtis

Reputation: 103348

This is most likely a setting with whatever software you are using to print this page.

If you are using a web browser, the browser may be removing the colours to save ink etc.

These settings can usually be changed within the browser software itself. I don't think there is anything you can change on your web application to force this background-color.

Upvotes: 1

Related Questions