1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

What are the best practices when using print stylesheet?

Discussion in 'HTML & Website Design' started by badger_, Dec 5, 2016.

  1. #1
    When I use a print.css this way:
    
    <link rel="stylesheet" href="/theme/print.css" media="print">
    
    Code (markup):
    All the browsers I tried download that file along with screen.css, despite being web browsers and not printers. Am I missing something? what are the best practices to do this?
     
    Solved! View solution.
    badger_, Dec 5, 2016 IP
  2. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #2
    It is not the printer that evaluates the print.css, but the browser when a print instruction is received. Click file>print preview. The print css file is simply cached, waiting for it to be needed. When you print, then the browser sends the print version to the printer.

    cheers,

    gary
     
    kk5st, Dec 5, 2016 IP
  3. #3
    Browsers really inhale upon the proverbial equine of short stature on this one, as they ALL handle it different, NONE of them bothers obeying the rules or intent of having media targets for print, etc, etc...

    Because IE and FF by default will ASSUME there is "no such thing as print support" and apply screen.css first, if you want JUST your print rules applied you need to override ALL your screen media styles. Even if you do this, be aware that both of those browsers thanks to their pre-CSS legacy cruft will ALSO apply their own styling rules overriding your own that you will fight with nonstop. There is -- or at least was -- an option buried for disabling that behavior in the browser itself, but that does you no good if the visitor to your page doesn't know how to do that or can't be bothered.

    I've not even checked what Safari/Chrome does, but can't imagine it's much better. Only REAL Opera (12.x/earlier) ever implemented "print" properly, and that's gone and shit the bed ever since Opera just slapped their logo over Chrome any-old-way and told their handful of loyal fans to go **** themselves.
     
    Last edited: Dec 5, 2016
    deathshadow, Dec 5, 2016 IP