Blocks may have margins. When blocks are adjacent to each other (visually, not
necessarily in the HTML document flow), the current CSS model specifies that the
margins sometimes collapse into each other.
(http://www.w3.org/TR/CSS21/box.html#collapsing-margins has the details.)
The rules currently defined may not provide what HTML / CSS authors want for
their pages. CSS can add the following:
'margin-collapse', 'margin-collapse-xâ€™, 'margin-collapse-yâ€™
Value: normal | none | min | max | all
Initial: normal
Applies to: all elements except elements with table display types other
than table-caption, table and inline-table
Inherited: no
Media: visual
normal use normal margin collapse behaviors.
none no collapse, use both full margins.
min use only minimum (smallest) margin.
max use only maximum (largest) margin.
all collapse all margins, draw none. Place borders next to each other.
margin-collapse sets both (x and y) directions. margin-collapse-x and
margin-collapse-y, set horizontal and vertical directions separately.
To handle the case where adjacent elements (left-right or top-bottom) have
different margin-collapse styles, some disambiguating rule needs to be
formulated. I am currently considering (mostly because it is simple) the FIRST
element's style applies. (First means the left in left-right or top in top-bottom.)
[Questions to consider:
If there is no margin to collapse (e.g., the start or end of a row, or top or
bottom of a block), the padding of the parent block may lie (visibly) adjacent
to the margin of the contained block. Would the padding be added to the margin
or should the margin collapse there as well? In some cases, the current margin
collapse rules specify that the margin collapses into the parent padding; in
others, there is no collapse. I hope that margin-padding-collapse is not
necessary, as this gets entirely too complex.
Should margin-collapse allow control of individual sides, such as
margin-collapse-left and margin-collapse-top? In this case, which prevails if
only one is set or if they are set differently?]
--
James Elmore