Posted over 2 years ago. Visible to the public. Repeats. Linked content.

Printing background color of elements

Browsers' printing methods usually don't print background colors. In most cases this is the desired behavior, because you don't want to spent tons of ink printing the background of a web page. But in some cases you want to print the background color of elements, e.g. bars of a chart. For those elements you need to set the following css styles:

Copy
-webkit-print-color-adjust: exact; /* Chrome and Safari */ color-adjust: exact; /* Firefox */

Note that if you're using autoprefixer, you don't need to add the prefixed variant yourself.

makandra has been working exclusively with Ruby on Rails since 2007. Our laser focus on a single technology has made us a leader in this space.

Owner of this card:

Avatar
Natalie Zeumann
Last edit:
7 months ago
by Dominik Schöler
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Natalie Zeumann to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more