tags:

views:

425

answers:

2

I have the following CSS for my print style:

* {
 display:none;
}

#printableArea {
 display:block;
}

I expected this to hide ALL elements, and only show the printableArea, however EVERYTHING gets hidden. So, in print view, all I get is a blank page.

I have it included properly in the HEAD, with media="print" on this particular stylesheet.

I'm sure I'm just overlooking something simple, but can someone please help? :(

+4  A: 

If an element is not displayed, then none of its children will be displayed (no matter what their display property is set to).

* matches the <html> element, so the entire document is hidden.

You need to be more selective about what you hide.

David Dorward
Ah, thanks! I guess I could just place printableArea outside of the page wrapper, then hide the wrapper, showing the print div.
FatherCarbon
+1  A: 
html body * {
 display:none;
}

#printableArea {
 display:block;
}

Also, you may need an !important on #printableArea, but probably not.

PHLAK
This will only work if #printableArea is a direct child of body.
Bennett McElwee