I have a line of text I would like to display only when a webpage is being printed. Is it possible to only display this line when printing the page or doing a print preview using PHP in some way?
Basically, I want to print a page without the print headers, but would like to include the page’s URL within the page’s content when it is printed.
2
You can create a CSS stylesheet that only applies to Print media.
For example:
Notice the media----v
<link rel="stylesheet" href="print.css" type="text/css" media="print" />
In your regular CSS stylesheet, just hide that element:
p.print-notice {
visibility: hidden;
}
And in your print CSS stylesheet, bring it up again:
p.print-notice {
visibility: visible;
}
Note: Setting visibility to hidden, only hides the element but does not remove it from the document flow. Use the Display property if you want to remove it from flow.
You might have more luck doing this with CSS and just showing or hiding the element(s) when printing using “@media print”. A little more information is here: http://webdesign.about.com/cs/css/qt/tipcssatmedia.htm but you can probably find more by doing some searches for CSS media types.