开发者

How to hide text with CSS when printing a page [duplicate]

开发者 https://www.devze.com 2023-03-12 10:17 出处:网络
This question already has answers here: 开发者_如何学C Closed 11 years ago. Possible Duplicate: How do I hide an element when printing a web page?
This question already has answers here: 开发者_如何学C Closed 11 years ago.

Possible Duplicate:

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

I would lilke to hide text on a page when the visitor prints.

The text resideds in a

<tr><td>Don't show me</td></tr>

It is not wrapped in a DIV ID, or Class... so I am wondering with CSS can you hide this portion of text... ?? Would you use CSS selectors?


Use the @print media type in your css to assign a specific styling (like display: none) to prints only.


You can hide it if you can select it but based on just one line of html it´s impossible to say whether you can just select that table cell.

I think adding something like a no_print class is your safest bet.

Obviously in combination with a print-specific style-sheet.


To do this, simply add

    @media print {

   .dontPrint {
       display:none;
    }

    }

Then in the part you dont want to print add class="dontPrint"

So for you, you could just do the following

<tr><td class="dontPrint">Don't show me</td></tr>

Now that part won't print

0

精彩评论

暂无评论...
验证码 换一张
取 消