Is there an opposite to display:none?

Issue

The opposite of visibility: hidden is visibility: visible. Similarly, is there any opposite for display: none?

Many people become confused figuring out how to show an element when it has display: none, since it’s not as clear as using the visibility property.

I could just use visibility: hidden instead of display: none, but it does not give the same effect, so I am not going with it.

Solution

display: none doesn’t have a literal opposite like visibility:hidden does.

The visibility property decides whether an element is visible or not. It therefore has two states (visible and hidden), which are opposite to each other.

The display property, however, decides what layout rules an element will follow. There are several different kinds of rules for how elements will lay themselves out in CSS, so there are several different values (block, inline, inline-block etc — see the documentation for these values here ).

display:none removes an element from the page layout entirely, as if it wasn’t there.

All other values for display cause the element to be a part of the page, so in a sense they’re all opposite to display:none.

But there isn’t one value that’s the direct converse of display:none – just like there’s no one hair style that’s the opposite of “bald”.

Answered By – Paul D. Waite

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published