How to only show certain parts with CSS for Print?

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>

Leave a Comment