You can easy set width to auto with margin:0px, auto
#container{
background-color: blue;
height:600px;
width:600px;
margin:0px auto; }
<div id="container"></div>
But why can't you set height to auto with margin:auto 0px? I mean, Why doesn't margin: auto 0px; vertically center a block as margin: 0px auto; horizontally centers it?
#container{
background-color: blue;
height:600px;
width:600px;
margin:0 auto; }
<div id="container"></div>