There are two questions.
-
Firstly, if there is no height set on divs, and there is no element
contained inside them, won’t they display at all? -
Secondly, depending on the first question, if I want to display a
div to be 90% of the body height and centered both horizontally and
vertically, even if there is no content inside of it, what is the
css required?
To completely centre a div (or any block element) you should use absolute positioning in combination with negative margins. Take a look here: enter link description here. Try resizing the window: it’s positioning happens automatically.
Of course, when you are only using percentual values, it is easier to just do the math: 50% – 45% = 5% (as Zeta’s post suggest) but I used this method to show that this works with non-percentual values as well. Example.
When an element does not have a specific height and it doesn’t have content, you will not see it, no. It will have an automatic width (normally 100%) but no height. You can make it visible though, by adding a border: http://jsfiddle.net/TALAA/2/