CSS - opposite of display:none

itsme picture itsme · Apr 28, 2014 · Viewed 19.5k times · Source

I'm trying setting up two simple css classes to toggle elements :

.hide{
  display:none;
}

.show{
  display:inherit;
}

It seems to work but sometimes display:inherit; return troubles so which is the exact opposite of display:none; ?

Answer

Dryden Long picture Dryden Long · Apr 28, 2014

This all depends on the element you are specifying. For example <div> and <p> elements are display:block; by default, whereas <span> is display:inline; by default.

The accepted answer here provides a list of the defaults for each element based on what browser is being used.

EDIT

It appears that display: initial; will work in most browsers, although not IE. A fallback line of CSS would probably be best practice:

.show {
    display: block;
    display: initial;
}