Re: The canvas

L. David Baron writes:
> Section 14.2 of CSS2 says both of the following [1]:
> 
> # Margins are always transparent so the background of the parent box
> # always shines through.
> 
> # The background of the box generated by the root element covers the
> # entire canvas.
> 
> Therefore, one of the following must be true:
> 
>  * The margins of the root element are colored by the background of
>    the root element
>  * The root element cannot have margins.
>  * The background of the box generated by the root element covers
>    the entire canvas minus the margins of the root element.  (This
>    doesn't make much sense to me since the canvas can be much bigger
>    than the root element if the children of the root element overflow -
>    for example, wide tables or preformatted text.)
>  * Something else??
> 
> I suspect it's the first of these possibilities, but I'm not sure.
> Which one is correct?

The first one is indeed what is intended. Look at it like this:

   1. the background (and margins, border, etc.) of the HTML and BODY
      elements are no different from any other element: backgrounds
      are positioned from the upper left padding edge, margins are
      transparent, etc.

   2. there is no selector for the canvas (since it is not an
      element), so where do we get its color from? we could have
      introduced a pseudo-element or an @-rule, but we chose to follow 
      HTML practice, and let the canvas "steal" the background from
      the BODY element.

   3. But what about SGML? (and now: XML) there is no BODY element,
      but there is always a root element, so we extend the rule to let 
      the canvas steal the background of the root element, with the
      exception for HTML that BODY may also be used.

Conclusion: the margins of HTML and BODY are still transparent; what
you see through them is the canvas.

Neither CSS1 nor CSS2 is very explicit about the origin (0,0) of the
canvas background, but it seems to me that the best result is obtained
if the canvas background is aligned with that of the element from
which it steals its background.


CSS recommends leaving HTML's background transparent for three
reasons:

  - so that everybody does the same thing, and thus cascading works
    better,

  - because that is the model that HTML introduced,

  - because some browsers have trouble with properties on HTML,
    (because the style sheet is created *after* the root element).



Bert
-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos/                              W3C/INRIA
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France

Received on Friday, 19 November 1999 09:34:56 UTC