I know the question is half old, but I'll give you a solution and anyway it stays there as a record.
By default printers do not print anything that is in CSS as background , be it image or color
To print the styles of background
, the user must choose background graphics in the printer settings as in the image below
AsalreadydiscussedinthesetwoquestionstheprinterbyDefaultdidnotprintanythingthatisbackground
inCSS,neitherimages,norcolors,oranything.
Print page with Background
Apply watermark without affecting the text
But there are techniques that can solve this problem. As I'll show below.
The first step is to create your unique CSS that will only use @print
See the example below working, the color will turn red in the printout. The technique is to apply a box-shadow
to the cell, so you can put the color you want and it will appear in the print without problems.
You can test here by giving Ctrl + P that will work!
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
table thead tr th {
background: greenyellow; /* cor antes da impressão */
}
@media print{
table thead tr th{
box-shadow: 0 0 0 1000px red inset; /* cor para impressão */
}
}
<div class="container">
<table border="1">
<thead>
<tr>
<th>Item 1</th>
<th>Item 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Texto 1</td>
<td>Texto2</td>
</tr>
</tbody>
</table>
</div>
Result of printing with the above code, notice the red box!
IfyouwanttosimulatehowyourimpressionisgoingtogorightonthepagewithouthavingtopressCtrl+PallthetimejustenableChrome's"Print Preview" directly by typing < kbd> F12 :