Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS How to print a table with background color (without Print settings changes)

Tags:

css

html-table

The aim is to print table with colored td-s. I need a way correct for all types of browsers.

Is there any way?

like image 700
maria Avatar asked Feb 24 '11 21:02

maria


People also ask

How do I change the background color of a table in CSS?

The background color of the table is given by the bgcolor="color" attribute. When applied to the <table> tag, the color fills the background. Cell background colors are set by applying the bgcolor attribute to a <tr> tag (to color the row) or to a <td> tag (to color the cell).

How can you specify background color in a table?

The HTML <table> bgcolor Attribute is use to specify the background color of a table. Attribute Values: color_name: It sets the text color by using the color name. For example “red”.

Why is my printer not printing the background color?

First on the File menu, click Options > on the Display menu, click to select the Print background colors and images check box under Printing Options > and then click OK. Hope above suggestion helps you and good luck! Was this reply helpful?


2 Answers

For webkit browsers (Chrome and Safari):

body{   -webkit-print-color-adjust:exact; } 
like image 185
drolex Avatar answered Oct 05 '22 19:10

drolex


Quote from here: CSS @media print issues with background-color;

IF a user has "Print Background colours and images" turned off in their print settings, no CSS will override that, so always account for that. This is a default setting.

Once that is set so it will print background colours and images, what you have there will work.

It is found in different spots. In IE9beta it's found in Print->Page Options under Paper options

In FireFox it's in Page Setup -> [Format & Options] Tab under Options.

like image 35
user194076 Avatar answered Oct 05 '22 19:10

user194076