Re: [CSS21] 8.4: "negative padding" meaning with percentages

On 03/11/2010 07:45, Peter Moulder wrote:
>    # Unlike margin properties, values for padding values cannot be negative.
>    # Like margin properties, percentage values for padding properties refer
>    # to the width of the generated box's containing block.
> In the case that the containing block's width is negative, it isn't clear
> whether this means that percentages aren't allowed to be negative (i.e.
> whether a negative percentage is considered an illegal value regardless
> of whether or not the containing block width is positive), or the used
> value isn't allowed to be negative, or both.

I agree that this isn't clear.  I think it wants to say that the used 
value isn't allowed to be negative.

> If the used value isn't allowed to be negative, then there needs to be
> some text saying what to do if the percentage calculation does give a
> negative answer (as might happen even if the percentage is a positive
> percentage if the containing block width is negative), for example
> stating that the used value is zero in this case (similar to 'min-width'
> and 'max-width').
> (My best reading of the existing text is that it should be treated as
>   an illegal value if the percentage calculation result is negative,
>   though this would be unfortunate, as it means that the cascade
>   resolution needs knowledge of the width of the containing block
>   to know which declarations should be discarded as illegal and thus
>   know to retain other declarations.)

I don't believe that padding: -20% should be illegal as a computed 
value.  The issue is that the rules for converting the computed value 
into the used value are currently flawed (insufficient).

It seems sensible that the used value should be 0 for a percentage on a 
property whose used values must be non-negative and where the percentage 
would ordinarily evaluate to something negative.

> 'min-width' and 'max-width' (10.4) have a similar issue in that
> the text says
>    # Negative values for 'min-width' and 'max-width' are illegal.
> but isn't completely clear whether negative percentages are illegal.
> If they are to be considered illegal, then I would suggest explicitly
> adding "(including negative percentage values)".

I'm trying to think of other examples in CSS21 where a legal computed 
value might be converted into an illegal used value according to the 
current wording in the spec.  I can't think of anything other than this 
percentages issue.  Possibly this crops up in CSS3; calc rings some 
warning bells.

Anton Prowse

Received on Saturday, 6 November 2010 12:54:38 UTC