user2045025 user2045025 - 2 years ago 428
CSS Question

Background color not showing in print preview

I am trying to print a page. In that page I have given a table a background color.
When I view the print preview in chrome its not taking on the background color property...

So I tried this property:

-webkit-print-color-adjust: exact;

but still its not showing the color.

.vendorListHeading {
background-color: #1a4567;
color: white;
-webkit-print-color-adjust: exact;

<div class="bs-docs-example" id="soTable" style="padding-top: 10px;">
<table class="table" style="margin-bottom: 0px;">
<tr class="vendorListHeading" style="">
<th>PO Number</th>
<th>Quote Number</th>
<th>Account Mgr</th>
<th>Shipping Method</th>
<th>Shipping Account</th>
<th style="width: 184px;">QA</th>
<th id="referenceSO">Reference</th>
<th id="referenceSO" style="width: 146px;">End-User Name</th>
<th id="referenceSO" style="width: 118px;">End-User's PO</th>
<th id="referenceSO" style="width: 148px;">Tracking Number</th>
<tr class="">
<td>Jim B.</td>
<td>510 xxx yyyy</td>
<td id="referenceSO">12/23/2012</td>
<td id="referenceSO">Approved</td>


Answer Source

The Chrome css property "-webkit-print-color-adjust: exact;" works appropriately.

However, making sure you have the correct css for printing can often be tricky. Several things can be done to avoid the difficulties you are having. First, separate all your print css from your screen css. This is done via the @media print and @media screen.

Often times just setting up some extra @media print css is not enough because you still have all your other css included when printing as well. In these cases you just need to be aware of css specificity as the print rules don't automatically win against non-print css rules.

In your case, the -webkit-print-color-adjust: exact is working. However, your background-color and color definitions are being beaten out by other css with higher specificity.

While I DO NOT endorse using !important in nearly any circumstance, the following definitions work properly and expose the problem:

@media print {
tr.vendorListHeading {
    background-color: #1a4567 !important;
    -webkit-print-color-adjust: exact; 

@media print {
    .vendorListHeading th {
    color: white !important;

Here is the fiddle (and embedded for ease of print previewing)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download