How to hide HTML elements when you print your web page

If you have provided a facility to print a web page or form on your website and you would like to hide specific HTML elements (butons, checkboxes etc) in the final print output then you can add the following code in your CSS file and apply the class to the HTML element you do not want to display.

@media print {
.noprint {

Now if you have the following web page

Some Report here

After adding the CSS class the page will become like this

Some Report here

The final printed page will not show the Print button.

Be the first to comment

Leave a Reply