Hi Ezio

Many thanks for all your effort with this problem.
Thanks also for the full explanation and link.
I'm not sure what happens now. Will somebody fix it?
I think it's important for Python's image because
it might be the first page a new user tries to print.

brimac


2009/10/6 Ezio Melotti <report@bugs.python.org>

Ezio Melotti <ezio.melotti@gmail.com> added the comment:

To fix this problem is enough to add an !important to the margin: 0;
rule in the @media print {} at the end of basic.css (line 408).

I'll try to explain why the !important is necessary.
In default.css @import url("basic.css"); (correctly) appears at the
beginning, and imports the rules from basic.css, including the @media
print {}. A few lines later, in default.css, there's the rule
div.bodywrapper { margin: 0 0 0 230px; }, and with no @media specified
it defaults on 'all'.

In default.css we then end up with something equivalent to:

/* This is defined in basic.css and imported
  at the beginning of default.css */
@media print {
   /* some rules omitted for clarity */
   div.bodywrapper { margin: 0; }
}

/* This is defined later in default.css */
@media all { /* This is implicit */
   div.bodywrapper { margin: 0 0 0 230px; }
}

When the file is printed both the rules are applied, because 'all' also
includes 'print'.
Since both the media have the same priority (i.e. the specific @media
print does NOT have higher priority than the implicit @media all) and
both the rules have the same priority too, the latter wins.
The !important is then needed to raise the priority of the first rule.

Note that adding the !important is not a really good solution IMHO: the
problem could appear again if other rules with the same priority of the
ones in @media print {} are specified elsewhere.
A good solution would be to move the print rules after the normal ones,
so in case the print media is used these rules will have higher priority.
The @import can only appear at the beginning of a file so the two
possible solutions are:

1) put the rules with media all in, for example, all.css and the ones
with media print in print.css and then, in default.css, write only:
@import url('all.css');
@import url('print.css') print;

2) like 1) but importing the print.css separately using <link> in the
html pages:
<link href="default.css" type="text/css" rel="stylesheet">
<link href="print.css" type="text/css" rel="stylesheet" media="print">

A third solution might be to specify the media of the normal rules to
'screen', but some rules are probably common to both the media.

More information here: http://www.w3.org/TR/CSS2/cascade.html

----------

_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue6670>
_______________________________________