Wilnar Vincent
Wilnar Vincent

Reputation: 82

PRINT: How to hide element and include element to print

Element should be hidden in media screen while include it when user want to print the page.

I use this CSS code but not working.

@media screen {
    th .hide {
      display: none;
    }
}

@media print {
    th .hide {
        border: 1px solid #000; 
        padding: 0.5em;
    }
}

html is like this:

<table>   
    <tr>
        <th class="hide" > Office:    
    </tr>
</table>

Upvotes: 1

Views: 746

Answers (1)

R&#233;my Testa
R&#233;my Testa

Reputation: 897

Here a similar post

The best practice is to use a style sheet specifically for printing, and and set its media attribute to print.

In it, show/hide the elements that you want to be printed on paper.

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

Upvotes: 1

Related Questions