Sasha Grievus Sasha Grievus - 1 year ago 78
CSS Question

How to hide all element on html page except one div using css?

I was trying to hide all on an html expect for one

, as part of a bigger problem.
I have tried...

body * {
display: none;
#someTable, #someTable * {
display: block !important;

But It doesn't work. What am i doing wrong?

Answer Source

You can use the pseudo-class ':not()'

   body *:not(.myDiv) {
        display: none;

<div class="myDiv">2</div>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download