> If I instead set a height on the same div, and then set margin: auto 0; it
> does not center horizontally.
I'm going to assume that you really meant vertically.
> Why? why why why?
Because the definition of "auto" states that if auto is the same for margin-left and margin-right,
then they will be equal. It doesn't specify the same rule for margin-top and margin-bottom, so auto
really ends up just acting as the default.
> Would the block center vertically if the containing block had a declared
> height, or does that not matter either?
It would not.
If you're in a position be able to specify height on both the block and it's container, then this is
pretty easy to accomplish. If you can't do that, then the only ways to do it are resorting to
<div class="middling parent">
<div class="middling child"></div>
position: relative; /* create a position context */
height: 10em; /* need to specify a height */
top: 50%; /* puts top in the middle of parent - requires that the parent has a height */
height: 3em; /* give the child height */
margin-top: -1.5em; /* negative top margin of half child height to move it back up to centered */
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/