Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
168
rated 0 times [  170] [ 2]  / answers: 1 / hits: 103980  / 13 Years ago, tue, june 28, 2011, 12:00:00

I am trying to implement a print feature in HTML. I know I can print the whole page with window.print(), but how do I print only a specific page element? For example a particular <DIV>Some text to print</DIV>.


More From » html

 Answers
15

You could use a print specific CSS stylesheet and hide everything but what you want printed.



<div class=no-print>I won't print</div><div class=something-else>I will!</div>



Just the no-print class will be hidden, but anything with a print class will show.



<style type=text/css media=print>
.no-print { display: none; }
</style>

[#91472] Saturday, June 25, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
makiyac

Total Points: 470
Total Questions: 100
Total Answers: 115

Location: Botswana
Member since Sat, Jan 7, 2023
1 Year ago
makiyac questions
Sun, Jan 16, 22, 00:00, 2 Years ago
Thu, Dec 17, 20, 00:00, 4 Years ago
Fri, Dec 4, 20, 00:00, 4 Years ago
;