Reported by Øyvind Stenhaug
10.6.3 contains various editorial problems:
1. Talks about "child box"es even though the formatting structure is
basically undefined (if interpreted as "child element's box" it's even
2. In the "block-level children" case, defines height as the distance
between edges of boxes that do not have margins collapsed through it -
what if there is no such box?
3. What if the "topmost block-level child box" has clearance? This case
doesn't seem to be considered.
4. The case of no content at all probably requires special mention too
I proposed the following solution in http://lists.w3.org/Archives/Public/www-style/2011Feb/0492.html
The top border edge position of the element, and hence the location of the top content edge, is well-defined elsewhere in the spec and needs no explanation in this paragraph. To determine the height of the element, it's enough to determine the bottom content edge E.
Let Z be the bottommost in-flow block-level child box. If the bottom margin of Z does not collapse with the element's bottom margin, then E is incident with Z's bottom margin edge. Otherwise, let Y be the bottommost in-flow block-level child box whose top and bottom margins do not collapse together. If Y exists then E is incident with the bottom margin edge or the bottom border edge of Y depending on whether the bottom margin of Y does or does not collapse with the element's bottom margin. Otherwise, or if Z does not exist, the element's height is zero.
[By "bottom margin" of an element X we really mean (due to margin collapsing) the margin lump of which the bottom margin of X is a constituent part.]
That is a non-trivial result, but it follows from other parts of the spec (including complex parts concerning margin collapsing, clearance, etc). On the other hand, it's also an intuitively obvious result. No justification for this result needs to be given in 10.6.3; it merely needs to be stated.
UPDATE: in fact the spec was actually changed between PR and REC, and now says the following:
# The element's height is the distance from its top content edge to
# the first applicable of the following:
# 1. the bottom edge of the last line box, if the box establishes
# a inline formatting context with one or more lines
# 2. the bottom edge of the bottom (possibly collapsed) margin of
# its last in-flow child, if the child's bottom margin does not
# collapse with the element's bottom margin
# 3. the bottom border edge of the last in-flow child whose top
# margin doesn't collapse with the element's bottom margin
# 4. zero, otherwise
Unfortunately this isn't quite true. A parent whose final two in-flow children are a self-collapsing element C with clearance followed by a self-collapsing element without clearance has its bottom content edge incident with the bottom *margin* edge of C not the bottom *border* edge of C, so (3) is wrong.
I maintain that my proposal in Comment 1 is correct. However, I note that using the criteria "does top margin of child collapse with bottom margin of parent" is a neat idea, and with this my proposal can be further simplified. Reframing it in the style of the spec text above, the proposal is now to replace (2) and (3) above as follows:
| 2. the bottom border edge of the last in-flow child whose
| bottom margin but not top margin collapses with the
| element's bottom margin
| 3. the bottom margin edge of the last in-flow child whose
| bottom margin does not collapse with the element's
| bottom margin
Note that the latest spec change was Issue 225. Note that all the proposals discussed by fantasai and myself in the thread beginning http://lists.w3.org/Archives/Public/www-style/2011Apr/0132.html (which try to reword the proposal described in Comment 1) were in fact incorrect, including the proposal that made its way into the spec. :-(
Issue 225: http://wiki.csswg.org/spec/css2.1#issue-225
Auto height calculation rules confused about margin collapsing
http://lists.w3.org/Archives/Public/www-style/2011Apr/0160.html (first part)
Open. =Bert= Edit. =Anton= Review.
I've posted my suggestion made in Comment 2 to the public mailing list: http://lists.w3.org/Archives/Public/www-style/2012Feb/0220.html
Another editorial problem with this section:
# The element's height is the distance from its top content edge
# to the first applicable of the following:
# 4. zero, otherwise
We should replace
# 4. zero, otherwise
| 4. the element's (incident) bottom content edge (ie the height is
since there's currently a grammatical mismatch with the sentence
which introduces the list.
Note that the original proposal (see Comment 1) and the alternative proposal (Comment 2) both suffer from analogous issue to that described in Bug 15748, namely that bottom margin edge is not defined when the margin participates in collapsing.