- From: Bert Bos <bert@w3.org>
- Date: Wed, 27 Oct 2010 18:02:31 +0200
- To: "www-style@w3.org" <www-style@w3.org>
Here is my review of the proposed text: On Wednesday 22 September 2010 15:42:26 fantasai wrote: > This is for CSS2.1 Issue 159 > http://wiki.csswg.org/spec/css2.1#issue-159 > triggered by this email > http://lists.w3.org/Archives/Public/www-style/2010Feb/0015.html > > This is version 6. > > In 9.4.1 append "for their contents" to "establish a new block > formatting context". > > Rewrite 8.3.1 as: > | In CSS, the adjoining margins of two or more boxes (which might > | or might not be siblings) Boxes can adjoin, elements can have siblings. To avoid issues such as the one we had for "ancestor box," let's be clear that this actually means: "which might or might not be *generated by* siblings". But to avoid such verbose rules, I propose we continue to conflate the boxes and the elements that generate them, when there is no ambiguity. In particular, terms such as child and sibling refer to the tree relation between the elements, while terms such as top and adjoining refers to the spatial relation between the boxes. But it may be good to state that somewhere explicitly. > | can combine to form a single margin. > | Margins that combine this way are said to <dfn>collapse</dfn>, > | and the resulting combined margin is called a <dfn>collapsed > | margin</dfn>. > | > | Adjoining vertical margins collapse, except: > | * Margins of the root element's box do not collapse. > | * If the top and bottom margins of an element with clearance > | are adjoining, its margins collapse with the adjoining margins > | of following siblings but that resulting margin does not > | collapse with the bottom margin of the parent block. > | Horizontal margins never collapse. > | > | Two margins are adjoining if and only if: > | * both belong to in-flow block-level boxes that participate in > | the same block formatting context > | * no line boxes, no clearance, and no non-empty padding or > | border areas separate them That parses as: [non-empty [[padding or border] areas]]. To find that structure, you have to read the sentence at least twice. Maybe the shortest version is the best: "... no clearance, no padding, and no border separate them." > | * 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 > | - bottom margin of box and top margin of its next in-flow > | following sibling > | - 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. Do we need this sentence? I don't see any occurrence of a collapsed margin adjoining another margin below. I think this might be meant to make the last of the notes below true. In which case it should probably say something like: "Margins A and B collapse if there is a margin C such that both A collapses with C and B collapses with C." And then it should be a list item in the list above, not a paragraph after the list. > | > | Note. Adjoining margins can be generated by elements that are not > | related as siblings or ancestors. > | > | Note the above rules imply that: > | * Vertical margins between a floated box and any other box do > | not collapse (not even between a float and its in-flow > | children). > | * Vertical margins of elements that establish new block > | formatting contexts (such as floats and elements > | with 'overflow' other than 'visible') do not collapse with > | their in-flow children. The above two items have the word "vertical," the two below don't. To avoid questions, I suggest to remove "vertical" as we already know that we're only talkking about vertical margins anyway. > | * Margins of absolutely positioned boxes do not > | collapse (not even with their in-flow children). > | * Margins of inline-block boxes do not collapse (not even with > | their in-flow children). > | * The bottom margin of an in-flow block-level element always > | collapses with the top margin of its next in-flow block-level > | sibling, unless that sibling has clearance. > | * The top margin of an in-flow block element collapses with > | its first in-flow block-level child's top margin if the > | element has no top border, no top padding, and the child has > | no clearance. > | * The bottom margin of an in-flow block box with a 'height' of > | 'auto' and a 'min-height' of zero collapses with its last > | in-flow block-level child's bottom margin if the box has no > | bottom padding and no bottom border and the child's bottom > | margin does not collapse with a top margin that has clearance. > | * A box's own margins collapse 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) collapse. Does this actually follow from the rules above? It should, but I haven't quite found how yet. Need to study this more... > | > | When two or more margins collapse, the resulting margin width is > | the maximum of the collapsing margins' widths. In the case of > | negative margins, the maximum of the absolute values of the > | negative adjoining margins is deducted from the maximum of the > | positive adjoining margins. If there are no positive margins, the > | maximum of the absolute values of the adjoining margins adjoining > | margins is deducted from zero. > | > | If the top and bottom margins of a box are adjoining, then it is > | possible for margins to collapse through it. In this case, the > | position of the element depends on its relationship with the > | other elements whose margins are being collapsed. > | * If the element's margins are collapsed with its parent's top > | margin, the top border edge of the box is defined to be the > | same as the parent's. > | * Otherwise, either the element's parent is not taking part in > | the margin collapsing, or only the parent's bottom margin is > | involved. The position of the element's top border edge is > | the same as it would have been if the element had a non-zero > | bottom border. > | Note that the positions of elements that have been collapsed > | through have no effect on the positions of the other elements > | with whose margins they are being collapsed; the top border edge > | position is only required for laying out descendants of these > | elements. > > ~fantasai I like the organization of the text. Much better than the organically grown set of paragraphs in the current spec. Bert -- Bert Bos ( W 3 C ) http://www.w3.org/ http://www.w3.org/people/bos W3C/ERCIM bert@w3.org 2004 Rt des Lucioles / BP 93 +33 (0)4 92 38 76 92 06902 Sophia Antipolis Cedex, France
Received on Wednesday, 27 October 2010 16:03:05 UTC