How do I print the indicated div (without manually disabling all other content on the page)?
I want to avoid a new preview dialog, so creating a new window with this content is not useful.
The page contains a couple of tables, one of them contains the div I want to print – the table is styled with visual styles for the web, that should not show in print.
Best Answer
Here is a general solution, using CSS only, which I have verified to work.
Alternative approaches aren't so good. Using
display
is tricky because if any element hasdisplay:none
then none of its descendants will display either. To use it, you have to change the structure of your page.Using
visibility
works better since you can turn on visibility for descendants. The invisible elements still affect the layout though, so I movesection-to-print
to the top left so it prints properly.