W3C home > Mailing lists > Public > www-style@w3.org > January 2009

Re: [CSS21] Negative clearance

From: Anton Prowse <prowse@moonhenge.net>
Date: Sat, 03 Jan 2009 13:33:11 +0100
Message-ID: <495F5B07.4060404@moonhenge.net>
To: "www-style@w3.org" <www-style@w3.org>

fantasai wrote:
> Anton Prowse wrote:
>>  From CSS21:
>> Clearance is introduced as spacing above the margin-top of an element. 
>> [...] Computing the clearance of an element on which 'clear' is set is 
>> done by first determining the hypothetical position of the element's 
>> top border edge within its parent block. This position is determined 
>> after the top margin of the element has been collapsed with previous 
>> adjacent margins (including the top margin of the parent block).  If 
>> this hypothetical position of the element's top border edge is not 
>> past the relevant floats, then its clearance must be set to the 
>> greater of:
>>    1. The amount necessary to place the border edge of the block even 
>> with the bottom outer edge of the lowest float that is to be cleared.
>>    2. [...]
>> Firstly, it is not clear from a naive reading of expression (1) above 
>> that the amount described can be a negative quantity (and hence that 
>> clearance itself can be negative); only when the assumption is made 
>> (as affirmed in [1]) that the presence of non-zero clearance on an 
>> element prohibits margin-collapsing of that element's margin top with 
>> all non-descendant elements does the spec make sense to me.  If this 
>> is the correct reading, could this assumption not be made clearer?
> There's a note where clearance is defined
>   http://www.w3.org/TR/CSS21/visuren.html#flow-control
> that says that clearance can be negative.

I intended to mean "can" in the sense of "is mathematically possible" 
rather than "is permitted by the specification".  One has to think 
rather carefully to picture a situation in which negative clearance 
would occur.  As I say, only when you take note of the fact that 
negative clearance prevents margin-collapsing(*) does it become clear: 
if zero is not by coincidence the correct clearance, then non-zero 
clearance is required, which immediately implies that margin-collapsing 
is prohibited thus forcing the margin box "downwards", and then it is 
easy to see that we might well have to "pull up" using negative clearance.

Hence my initial reaction on reading the note you cite has often been, 
"remind me when!", and I have to think about it all over again.  My 
request was merely that this fact is made easier to see, perhaps by way 
of an example.

(*) I find it more intuitive that /positive/ values prevent margin 
collapsing, although I do not claim that it is reasonable that I should 
find one case more intuitive than the other!

> That clearance causes margins to not collapse is specified in 8.3.1:
>   http://www.w3.org/TR/CSS21/box.html#collapsing-margins

Thanks, I did overlook that.  Hence what I claimed above was an 
assumption is in fact an axiom.  (For some reason I was thinking that 
the situations in which margin collapsing was prevented were discussed 
individually near to each relevant property etc rather than listed 
together in 8.3.1.)  An example in the clearance section would serve the 
extra purpose of reminding us of this.

>> Secondly, whilst the presence of negative clearing results in a 
>> rendering in which the margin-top of the clear appears to 
>> disappear[1], the implication in the spec is that it doesn't really 
>> disappear but that instead there is "negative spacing" above the 
>> margin top.  To me the result seems rather like "position: relative; 
>> top: <negative-clearance>".  Yet take for example [2];  if the 
>> margin-top of 50px is "still there", why doesn't it overlay the first 
>> div, thus covering the hyperlink and making it unclickable?
> Margins are transparent. I would expect them to be transparent wrt
> events as well as to color.

Ok.  I don't think that there's a statement in CSS21 to the effect that 
margins are transparent to interaction as well as visually --- to the 
extent that the spec could equivalently say that margins are not 
rendered at all and are "merely" a calculation device --- but probably 
this is not in CSS21's remit.  (Note that CSS3 deals with ::selection, 
so perhaps the question of exactly what can be reached in order to 
select it is more pertinent there.)

Received on Saturday, 3 January 2009 12:33:59 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:38:23 UTC