Re: Center DIV

J. King wrote:
> margin:auto not centering vertically has always seemed to me like a 
> limitation that was overlooked because of the continuous nature of 
> HTML.

Not "overlooked", so much as "designed out".

When you consider the CSS box model, there is a fundamental asymmetry 
between width and height.  In particular, for normal block layout:

For width, the width of a block is determined by ancestors of the block 
and its own styling.

For height, the height of a block is determined by descendants of the 
block and its own styling (this leads to things like "percentage height 
means auto height if the parent height is auto").

This asymmetry was certainly introduced because of the abovementioned 
continuous nature of HTML.

There are parts of the CSS2 specification that do not have that 
asymmetry to quite the same degree -- to whit, table cells shrink-wrap 
in the horizontal direction.  You will note, however, that the layout 
algorithms for these are completely unspecified ("fixed" table layout 
does not count, since there is no shrink-wrapping involved there), which 
makes that part of the specification rather useless, really... 
(implementors have to code tables by reverse-engineering IE, because 
there is no spec to follow).

The point is, to solve the problems that people want to be solved, 
pretty much the entire box model would have to be thrown out and 
rewritten from scratch.  This would make the layout specified by 
whatever version of CSS does this be be different than the layout 
specified by CSS1/CSS2 in many cases (one could perform bizarre spec 
gyrations to avoid it, but the result would only be an unimplementable 
spec)...

As it happens, Mozilla does implement two box models -- the CSS box 
model for HTML/generic-XML and the XUL box model for XUL (this latter is 
constraint-based and fits the needs of a UI-writer as opposed to those 
of a document-writer).  The interaction of the two box models is rather 
ill-defined; they are essentially not usable together in the same 
document in any sane way.  I've not seen a way to make them be usable 
together thus far....

-Boris

Received on Friday, 4 July 2003 10:56:17 UTC