Reported by David Baron.
The 2010-12-07 WD (http://www.w3.org/TR/2010/WD-CSS2-20101207/box.html#collapsing-margins) and some previous CRs contained an internal contradiction in the case of an auto-height, non-zero min-height element with a single self-collapsing child. Section 8.3.1 said:
% The bottom margin of an in-flow block box with a 'height' of 'auto'
% is adjoining to its last in-flow block-level child's bottom margin
% if the element has no bottom padding or border.
% An element's own margins are adjoining if the 'min-height' property
% is zero, and it has neither top or bottom borders nor top or bottom
% padding, and it has a 'height' of either 0 or 'auto', and it does
% not contain a line box, and all of its in-flow children's margins
% (if any) are adjoining.
The former paragraph says that the parent's bottom margin adjoins the child's bottom margin (which adjoins its own top margin which adjoins the parent's top margin [via other rules not quoted here]). Yet the latter paragraph doesn't cover the case in question (since min-height is non-zero) and so the implication is that that the parent's top and bottom margin are not adjoining; this was either a contradiction (if one believes that adjointness was implicitly transitive) or else it was the exact same problem that the current spec, with its new wording and terminology, now explicitly suffers from:
In the current spec, 8.3.1 (Collapsing margins) says:
# Adjoining vertical margins collapse, except [omitted special cases]
# Two margins are adjoining if and only if:
# [omitted conditions]
# * both belong to vertically-adjacent box edges, i.e. form one of
# the following pairs:
# - top margin of a box and top margin of its first in-flow child
# [omitted pair]
# - bottom margin of a last in-flow child and bottom margin of
# its parent if the parent has 'auto' computed height
# - top and bottom margins of a box that does not establish a new
# block formatting context and that has zero computed 'min-height',
# zero or 'auto' computed 'height', and no in-flow children
# A collapsed margin is considered adjoining to another margin if any
# of its component margins is adjoining to that margin.
So in the case being discussed, the parent's bottom margin adjoins the child's bottom margin, which adjoins its own top margin which adjoins the parent's top margin... and rather than this resulting in a contradiction, it simply means that all margins explicitly collapse together, a pathalogical behaviour given that the parent has non-zero used height.
A sensible resolution which handles this case is needed.
Issue 211: http://wiki.csswg.org/spec/css2.1#issue-211
Transitivity error in margin collapsing
Open. =errata= Deferred to Errata
At the F2F in Paris 2012
[http://lists.w3.org/Archives/Public/www-style/2012Feb/0529.html] it was tentatively decided to prevent collapsing in the case described:
# - bottom margin of a last in-flow child and bottom margin of its
# parent if the parent has 'auto' computed height
| - bottom margin of a last in-flow child and bottom margin of its
| parent if the parent has 'auto' computed height and either the
| parent has a zero computed min-height or the bottom margin of
| the last in-flow child does not collapse with the top margin of
| the parent
See also the proposals in Bug 16037.
An updated proposal is: [http://lists.w3.org/Archives/Public/www-style/2012Mar/0052.html]
Add a new bullet to:
# "Adjoining vertical margins collapse, except:"
| - If the top margin of a box with non-zero computed 'min-height'
| and 'auto' computed 'height' collapses with the bottom margin of
| its last in-flow child, then the child's bottom margin does not
| collapse with the parent's bottom margin.
The WG resolved to accept the change in Comment 2 to close this issue.
Minutes of resolution: http://lists.w3.org/Archives/Public/www-style/2012Apr/0101.html
Created attachment 1132 [details]