Printing hidden text

Discussion in 'CSS' started by chanc6, Jan 23, 2008.

  1. #1
    I am trying to add a footer at the end of my html page. I want it to be hidden when the page is displayed, but want it show up when the page is printed.

    I tried something like the following, which I don't think is right.

            out.write("<div style=\"visibility:hidden\">");
            out.write("The hidden text");
            out.write("</div>");
    Code (markup):
            out.write("<div style=\"display:none\">");
            out.write("The hidden text");
            out.write("</div>");
    Code (markup):
    Any suggestions? Thanks.
     
    chanc6, Jan 23, 2008 IP
  2. ChaosFoo

    ChaosFoo Peon

    Messages:
    232
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Don't use Javascript to do this. Use CSS. You can actually specify to use a different CSS style sheet when printing. You can read more about it here:

    http://www.w3.org/TR/REC-CSS2/media.html

    You basically put something like this is your <head> tag.

     <LINK rel="stylesheet" type="text/css" media="print" href="print.css">
    Code (markup):
    Then you specify how you want the document to look when printed in the "print.css" file by using CSS.
     
    ChaosFoo, Jan 23, 2008 IP
  3. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ...OR...

    If your footer has a background colour, it gets better: make your text the same colour as the footer background colour. It's now invisible (watch out, google may delist a site with invisible text...). Printers usually default to NOT printing the background colours when printing in B&W (colour printing, though, would need the seperate CSS import like Foo said).
     
    Stomme poes, Jan 24, 2008 IP
  4. St. Anger

    St. Anger Banned

    Messages:
    211
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    use css by using background color same to the text...
    but using invisible text is not good with google :D
     
    St. Anger, Jan 24, 2008 IP