How do I hide an element when printing a web page?


To hide the element, add “display:none” to the element with CSS.

<style>
@media print {
   .noprint {
      visibility: hidden;
   }
}
</style>

In addition, add the element, which you want to hide inside the <div>−

<div id="noprint">
   Add here the element, which you want to hide.
</div>

Updated on: 24-Feb-2020

5K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements