CSS Design: Going to Print

by Eric Meyer

109 Reader Comments

Back to the Article
  1. Yep.

    Copy & paste the code below to embed this comment.
  2. A colleague has the problem of putting headers and footers on pages when printed out. I referrred him to this article, but that particular feature doesn’t seem to have been mentioned. I intend to dig into my css reference books, since css isn’t my main specialty, I thought I ask for pointers. Anyone?

    Copy & paste the code below to embed this comment.
  3. i use a xerox docuprint 4508. all the lights are flashing eg paper jammed. paper empty etc and it will not print. obviously the paper is not the problem yet this message flashes on screen also, printer out of paper, can some one advise… anne

    Copy & paste the code below to embed this comment.
  4. Im trying to print some white text on top of an image. The approach is a simple image, and a layer positioning the white text on top of the image.

    I have a stylesheet with a screen and print type, and i can see that the print version is used.

    However, no matter how i put it, once my text color reaches a certain “lightness”, it starts fading towards grey instead of white. Pure white will produce grey.

    If i make a pure green, it will print pure green. Taking that same color and adding a little red and blue into it will have it gradually fade to grey instead of white on print.

    Anyone have a solution to this?

    Copy & paste the code below to embed this comment.
  5. I recently replaced ink cartridges (on my Canon S750 printer) and I can no longer print e-mail. It will print when I highlight, “Copy” and “Paste” the subject onto “Write”. I was able to always print out e-mail or whatever from it’s original display prior to the ink replacement. What did I do wrong?
    Thanks for any help.

    Copy & paste the code below to embed this comment.
  6. Someone asked about !important. I hadn’t remembered seeing that before either. It is explained here: http://www.w3.org/TR/REC-CSS1#important

    Basically, if I understand it correctly, by adding !important to a style, that style is forced to take precedence even when another style may normally take precedence by default. So by adding !important to a style that is absolutely necessary (for printing in this case) we do not have to worry about it being overridden by, say, a style defined within the body of the doc. (Could this be a solution to a few problems some have mentioned here?)

    Btw, the above reference is only part of a section which explains how one style gets preference over another. The entire section 3 may be helpful to anyone that is not sure how this works.

    Hope this helps.

    Copy & paste the code below to embed this comment.
  7. Some have taken issue with the lack of a printer friendly link when utilizing this solution. Some workarounds have been addressed by others. If you must you can still create such a page, although I like the suggestion to use some very simple javascript to simply print the current page.

    However, in my experience, the average user often overlooks the printer friendly link and complains that pages do not print in such a way that they are readable, thereby negating the value of the option. This alleviates that problem by ensuring that all pages look as intended when printed, no matter the level of the user (which makes it the best solution in my view). And if you feel obligated to provide the link for the more knowledgable/ observant, then by all means do.

    Thank you ala for providing another great article (to bad I didn’t read it sooner). Even the least intelligent of visitors to my sites can get the intended results whenever I follow your excellent advice.

    Copy & paste the code below to embed this comment.
  8. This was a great article, as have been all the ones I’ve read here. But I still have a question about something that’s happening to a site I’m working on. If you go to this page http://www.sassllc.com/index.asp and do a Print Preview, it looks OK. But if you go to http://www.sassllc.com/FAQ.asp and do the same, the text gets squeezed to the left of the content box.

    Am I missing something really obvious?

    Thanks so much! (If there’s a more proper place for me to be asking this, please let me know and I will forthrightly comply!)

    Copy & paste the code below to embed this comment.
  9. Hi, im new at css and i need this. I want a print this button on my page so im gonna have that link to a new page and i wanna put in this code to make it printer ready.. Now if anyone has any better ideas i would like to know :). But i dont really understand this code, well some of it. Could someone, very simply, tell me exactly where i need to put everything and what i need to change. Thanks!

    Copy & paste the code below to embed this comment.
  10. Its me again, same guy as before. Ok say i already have a style sheet on my page, because i already do. This will still work with it right?? Another question is, does this only make the printed page come out different it doesnt make it on the net look different??? I need to know how to use this because im very new at css and this is complicated, ahhhhh. By the way, i want to also make a print this icon. How would i make that work so it automatically printed?

    Copy & paste the code below to embed this comment.
  11. Great article and making me change how our new site is formatted. However…
    Like someone else in this thread I have menus on the left and removing them with display: none just leaves a blank space with the content still shifted across the page.
    How do I get the content back to use the empty space to the left?

    Thanks in anticipation.

    Copy & paste the code below to embed this comment.
  12. I’ve used the similar
    alternate CSS to create a fixed point font size for printing. But both on that, and also your sample page, my IE6 continues to print as if the screen font is not changed. (NN6 is fine though). In other words, IE6 completely disregards the visible changes on the screen, although it DOES print out according to size if I use the mousewheel to resize the print.

    Is this a known Win IE6 problem? Is it my setup? Is there any way round it?

    Many thanks


    Copy & paste the code below to embed this comment.
  13. I cannot get the display: none to work. I’m using IE 6.0 to view my pages. I see it working on the article’s page but it isn’t working on mine. Ugh!!!!

    Copy & paste the code below to embed this comment.
  14. Very good article, I use tricks that explain and everithing works fine!

    Copy & paste the code below to embed this comment.
  15. Try {display: none !important;}

    Copy & paste the code below to embed this comment.
  16. Hi,

    First, thank you for a very good idea on print style sheets. I am a complete novice at this CSS thing so please be kind if the idea I’m about to suggest is flawed.

    I created a separate print style sheet as per the article and added it to my template with the following declaration:

    <style type=“text/css” media=“all”> import &#8220;styles.css&#8221;; &lt;/style&gt; <br /> &lt;link rel=&#8220;stylesheet&#8221; type=&#8220;text/css&#8221; media=&#8220;print&#8221; href=&#8220;print.css&#8221; /&gt; <br /> <br /> But I found that when I validated the CSS by URI it did so but the validator gave me warnings saying that I had several redefinitions in my CSS. Obviously the W3C validator reads both style sheets and adds them together, I don&#8217;t know. So I searched for a hack and couldn&#8217;t find anything until I came across the media tag.

    Within my style sheet (styles.css) I added the following:

    @media print {

    /* I then cut and pasted my print style sheet into this section */


    It worked great and validated correctly, naturally that meant I could remove the line.

    <link rel=“stylesheet” type=“text/css” media=“print” href=“print.css” />

    So now I have a single style sheet that does two jobs. Some of you gurus may already know about this technique but I thought I’d share it anyway, plus someone may be able to develop it further.



    Copy & paste the code below to embed this comment.
  17. While I find the solution discussed in this article interesting, sometimes you want to offer visitors more than just the same page with different looks.

    Is it possible to instruct the web browser to choose a specific document when the user wants to print a page? Something like
    <link rel=“printable” href=“resume.pdf” />
    that basicallt says: “if the user wants to print this page, use the document resume.pdf”.

    Copy & paste the code below to embed this comment.
  18. This is a great article but I’m working with a site currently built with tables. Most of the code has worked (getting rid of graphics, changing fonts, etc.), but my text is being cut off by the right margin of the printed page. I’m not sure if this is b/c of tables or some other problem. The content is the center column of a three column table. Left and right columns are set to display:none. Any ideas?

    Copy & paste the code below to embed this comment.
  19. I printed this article in Safari 1.0 (v85) and the main content wrapped to a column only about 25% the width of the page. From IE, it looked fine. Is there a something in the CSS that can fix this? Or perhaps it’s a browser-bug?

    Copy & paste the code below to embed this comment.