Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS/HTML/Javascript tricks to print a web page without images

I'm trying to put a print button on a web page that will print the page's contents except images. Any ideas?

like image 570
Resonance Sap Avatar asked Jul 01 '26 19:07

Resonance Sap


2 Answers

You can use CSS to disable all images on your website only when printing.

@media print {
  img {
    display: none !important;
  }

  * {
    background-image: none !important;
  }
}
like image 89
Andrew Moore Avatar answered Jul 03 '26 08:07

Andrew Moore


No need to use a button, unless you want to give people the option to print images or no images.

If you just want people to print without images (which is preferred most of the time), you can just use a print stylesheet.

<link rel="stylesheet" href="print.css" type="text/css" media="print" />

Then add

img {display: none;}

like image 38
Jason Gennaro Avatar answered Jul 03 '26 09:07

Jason Gennaro