How to only show certain parts with CSS for Print?
Start here. But basically what you are thinking is the correct approach.
Thanks, Now my question is actually becoming: How do I apply CSS to a class AND ALL OF ITS DESCENDANT ELEMENTS? So that I can apply "display:block" to whatever is in the "printable" zones.
If an element is set to display:none;
all its children will be hidden as well. But in any case. If you want a style to apply to all children of something else, you do the following:
.printable * {
display: block;
}
That would apply the style to all children of the "printable" zone.
A simple way:
<style>
.print-only{
display: none;
}
@media print {
.no-print {
display: none;
}
.print-only{
display: block;
}
}
</style>
If you want to display some links etc. when in the browser, that you don't want to be printed. Furthermore you have some logos and letterhead info that only should go on the printed page. This seems to work fine:
Example:
CSS:
@media print {
.noPrint {
display:none;
}
}
@media screen {
.onlyPrint {
display: none;
}
}
HTML:
<div class="noPrint" id="this_is_not_printed" >
<a href=links.html>
</div>
<div class="onlyPrint" id="this_is_only_seen_on_printer" >
<img scr=logo.png >
<img scr=letterhead.png >
</div>