Search code examples
htmlcssprintingxhtmlstylesheet

hide HTML div when printing page


I have a XHTML-based page which contains admin information. The admin should be able to print the page, but I would like it to hide their information.

Is there a way to set a print area when printing a page, or is the only viable solution to open up a secondary page without the admin information when clicking on the "print" button?

Thank you!


Solution

  • try this:

    <style type="text/css" media="print">
    .dontprint
    { display: none; }
    </style>
    
    <div class="dontprint">I'm only visible on the screen</div>