Context: creating instances for printing in a browser.
Typically, when creating web pages with a printer, the @media print rule is used to change how the content of a printed page is searched. Ideally, since I print only a small part of the page, I would like to hide everything and then display the contents of a specific element.
The structure looks something like this:
<body> <div id="topMenu">...lots of elements...</div> <div id="sideMenu">...lots more...</div> <div class="tools">...some tools...</div> <div class="printing">...some elements I want to print...</div> <div class="tools">...more stuff I don't want to print...</div> </body>
The material I tried:
Ideally, I would like to do something like
body * { display: none; } .printing, .printing * { display: block !important; }
But this will not work, because some elements must be inline and some must be block. I played with multiple display values โโfrom MDN and cannot find one that easily resets the value to its original. display: initial seems to be seen as inline .
CSS suggestion : "display: auto;" ? seems to work only for JS.
Of course, you can explain โhideโ material that I donโt want to print, and not display the things that I really want, but it seems to me that I need to go the other way.
In this question How to display only certain parts using CSS for printing? suggests body *:not(.printable *) {display:none;} but notes (when backing up on the w3 negation page ) that this is not yet supported.
I note that w3 draft and off-page display seem to recommend using the unknown (to webkit) box-suppress property to preserve the displayed value without displaying the element.
My questions:
What is the best way to hide everything and set certain elements to display when they do not all have a common display property?
What exactly does box-suppress do?