views:

1400

answers:

2

I have some simple CSS:

#someElement {
    background-color:black;
    color:white;
}

It looks ok in the browser, but when I go to print it in Firefox it comes out as black text on a white background. I imagine this is some sort of ink-saving feature, but is there any way around it?

+6  A: 

Its a browser setting. There is nothing you can do in your CSS. In Windows - File > Page Setup... > Print Background.

Daniel A. White
+4  A: 

Maybe not the answer you're looking for, but here goes:

I'd rather add a separate stylesheet for printing the page. Typically, you would want to remove things like navigation menus, breadcrumbs, ads, and maybe do some small changes in margins, paddings, borders and fonts compared to the on-screen stylesheet.

Even thinking about forcing the user to fill a whole page with black ink with white text seems silly to me.

To add a separate print stylesheet, add another stylesheet to the head of your page.

<link rel="stylesheet" href="print.css" type="text/css" media="print">
Arve Systad
Heh, a whole page would be excessive; I only wanted a small area.
machineghost
That might just be, but keep in mind it's the exact same mechanism that controls it. Should the browser detect the surface area in the website, check it against desired DPI settings somewhere for print and THEN decide wheather or not to apply the BG-color? ;-)
Arve Systad