Re: syntax of rect()

L. David Baron writes:
 > This problem came out of a discussion on netscape.public.mozilla.layout.
 > The CSS2 spec defines the syntax of the rect() [1] function (for the
 > clip property) as without commas:
 > rect (<top> <right> <bottom> <left>)
 > but then gives examples with commas:
 > P { clip: rect(5px, 10px, 10px, 5px); }
 > The W3C CSS2 validator [2] requires the commas, and Microsoft
 > documentation [3] on the matter gives the rect() function without
 > commas, as does Liam Quinn's CSSCheck[4].  I tend to think the CSS2
 > examples and the CSS2 validator are wrong, and both should be
 > corrected.  Is this the correct interpretation?

No, I think the example is right and the definition is wrong. All
other functional notations in CSS have commas (rgb(), format(),

It is better for extensibility to require a comma. It allows that the
simple values one day be replaced by expressions:

    rect(5px+10%, 10px, width/2, 5px)

without requiring extra parentheses.

It is also more in keeping with what people are used to in other

Both Netscape and MSIE currently accept with and without commas. Such
error recovery is counter to the spec and not a good idea in general,
but in this case it is probably not very dangerous.

However, the 'clip' property is at the moment almost unusable for
another reason, and that is that both MSIE and NS interpret right and
bottom in the opposite way from the spec: for them rect(0,0,0,0) means
completely invisible, while rect(0,100%,100%,0) is completely visible.
The spec has exactly the opposite. Some people claim that it is easier
to write scripts this way. It might become an erratum.

 > David
 > [1]
 > [2]
 > [3]
 > [4]

  Bert Bos                                ( W 3 C )                              W3C/INRIA                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France

Received on Thursday, 24 June 1999 16:54:51 UTC