How to hide text with CSS when printing a page [duplicate]
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
精彩评论