@media print

Discussion in 'HTML' started by Gregor Traven, Feb 17, 2005.

  1. Hi

    When I use @media print in my css, the browser doesn't even consider the
    values in this print section which were already defined furthermore in css.
    For example: if I have h1 {font-size:25px} then h1 {font-size:10px} in
    @media print section won't have any effect. Only the properties that haven't
    been used in css work if I define them in @media print section of css. Why
    is this so and can I do something to change it?

    Thanks for answering

    Gregor
     
    Gregor Traven, Feb 17, 2005
    #1
    1. Advertising

  2. "Gregor Traven" <> wrote:

    > When I use @media print in my css, the browser doesn't even consider
    > the values in this print section which were already defined furthermore
    > in css.


    I don't quite follow; what does "already defined furthermore" mean?

    > For example: if I have h1 {font-size:25px} then h1
    > {font-size:10px} in @media print section won't have any effect.


    It depends on the order. When rendering on print media, both rules are
    considered. Since they are otherwise equal, the one that comes later wins,
    by CSS rules. The @media print thing does not, somewhat unintuitively,
    affect the specificity.

    So if you have

    h1 { font-size: 25px; }
    @media print {
    h1 { font-size: 10px } }

    (which is poor practice in an author style sheet - px units are not
    suitable for setting font size)

    then the font size for h1 is 10px on print media, 25px on other media.
    If you swap the order, then the size is 25px for all media.

    If you wish to make the print-specific rule take priority independently of
    the order, use can declare it important:

    @media print {
    h1 { font-size: 10px !important; } }

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html
     
    Jukka K. Korpela, Feb 17, 2005
    #2
    1. Advertising

  3. Gregor Traven

    Toby Inkster Guest

    Gregor Traven wrote:

    > When I use @media print in my css, the browser doesn't even consider the
    > values in this print section which were already defined furthermore in css.


    URL?

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Feb 17, 2005
    #3
  4. "Jukka K. Korpela" <> wrote in message
    news:Xns9600E86245B91jkorpelacstutfi@193.229.0.31...
    > "Gregor Traven" <> wrote:
    >
    >> When I use @media print in my css, the browser doesn't even consider
    >> the values in this print section which were already defined furthermore
    >> in css.

    >
    > I don't quite follow; what does "already defined furthermore" mean?
    >
    >> For example: if I have h1 {font-size:25px} then h1
    >> {font-size:10px} in @media print section won't have any effect.

    >
    > It depends on the order. When rendering on print media, both rules are
    > considered. Since they are otherwise equal, the one that comes later wins,
    > by CSS rules. The @media print thing does not, somewhat unintuitively,
    > affect the specificity.
    >
    > So if you have
    >
    > h1 { font-size: 25px; }
    > @media print {
    > h1 { font-size: 10px } }
    >
    > (which is poor practice in an author style sheet - px units are not
    > suitable for setting font size)
    >
    > then the font size for h1 is 10px on print media, 25px on other media.
    > If you swap the order, then the size is 25px for all media.
    >
    > If you wish to make the print-specific rule take priority independently of
    > the order, use can declare it important:
    >
    > @media print {
    > h1 { font-size: 10px !important; } }
    >
    > --
    > Yucca, http://www.cs.tut.fi/~jkorpela/
    > Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html
    >
    >


    Thanks very much, what you wrote answered my question perfectly.

    Gregor
     
    Gregor Traven, Feb 18, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mika
    Replies:
    4
    Views:
    536
  2. kmsiever

    Re: media="print" css-problem?

    kmsiever, May 13, 2004, in forum: HTML
    Replies:
    1
    Views:
    394
  3. kmsiever

    Re: media="print" css-problem?

    kmsiever, May 13, 2004, in forum: HTML
    Replies:
    3
    Views:
    415
    Jukka K. Korpela
    May 15, 2004
  4. keto
    Replies:
    0
    Views:
    998
  5. David Cournapeau

    print a vs print '%s' % a vs print '%f' a

    David Cournapeau, Dec 30, 2008, in forum: Python
    Replies:
    0
    Views:
    373
    David Cournapeau
    Dec 30, 2008
Loading...

Share This Page