Re: backgroun color in media print

Giganews Newsgroups
Subject: Re: backgroun color in media print
Posted by:  Jukka K. Korpela (jkorpe…@cs.tut.fi)
Date: Mon, 4 Feb 2008

Scripsit Petr Vileta:

> I try to define this
> @media print {
>    span.red {border: 1px solid black;
>                            background-color: red}
> }

The name "red" is generally poor for a class: it says nothing about any
meaning, just the intended visual presentation. Anyone who only sees the
markup and the style sheet has little clue of what might be suitable for
a style sheet intended for black and white rendering, or aural
presentation.

> and use it in html code by this way
>
> <p>Color: <span class=red>&nbsp;&nbsp;&nbsp;</span> red</p>

Sounds your page is really _about_ colors and you wish to show what
"red" is (and you identify it with the meaning of the keyword red in
CSS). Then you should consider setting the width of the red box in CSS,
instead of the coarse and unreliable control you achieve by using
several no-break spaces.

> If I do the same for @media screen then this work as expected, but
> not for @media print.
> I can't to find if this is feature or cross browsers bug ;-)

It works as expected: browsers are more or less expected to ignore
background colors when printing, to avoid wasting ink. This however is
typically a browser configuration option.

> To explain what I can do: I want to create a small rectangle filled
> by some color, in this example red. I tried to use span, div, table,
> p, but nothing work for printer. What is the right way?

Using an image. Of course, it may or may not be printed, and the printer
may or may not be capable and configured to print colors.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Replies

None

In response to

backgroun color in media print posted by Petr Vileta on Mon, 4 Feb 2008