View Full Version : Print Just A Specific <div>

01-22-2004, 11:46 PM

I believe this can be done with CSS - How can I make it so that at print only a specific <div> within the page is printed. Also if this can be accomplished, the div's overflow is set to auto will it print the information that is overflowing? Currently I have a javascript that generates a tabular report displayed in the div, when the user goes to print it out anything that is not currently visible is cut off and not printed. The actual code is extremly lengthy so here is a non working example.

<style type="text/css">
<div class="noprint">A whole bunch of whatever</div>
<div class="print">The info I want printed</div>


01-23-2004, 12:00 AM
You can have another stylesheet that has the media set to print so that when the browser goes to print it uses that and you can hide all the divs you don't want to see and configure the one you how you please.

01-23-2004, 12:42 AM
Awesome **Smacking My Head**- I get it. Sometimes I just need a little push!!! :)

Thanks A Bunch,

01-23-2004, 05:01 PM
For me, I didn't want the navigation menu & page layout graphics to print, only the main body's content - so I specified which items are hidden and which can be displayed/printed, using a separate CSS specifically for printing only. Example of print.css:

.menu, .altmenu, .footer, .layout img {display: none;}
img, .content img, #body img, #content {display: inline;}

Since I use external CSS, I list the regular CSS as: media="screen"
and list the print CSS as: media="print"

Then you can just use the print preview button on your browser to see how it looks, without wasting paper or ink. :D