top-level element enigma

In the beginning there was CSS1. And somewhere in the specification was at
least one mention of specifying background properties on the HTML element.
This made sense to me at the time, since BODY could have margins and margins
allow the background of the parent element to show through.

Todd Fahrner recently argued for BODY as top-level element, with UA-default
style declarations applied directly to BODY. I countered with a plea for a
higher-level, absolutely-positioned HTML element, to allow access to the
"canvas" while retaining BODY as a block-level element with all the property
values of any other block-level element.

Neither model works, quite.

HTML cannot be fully accessible to style sheets. To fit the current CSS2
draft, the "canvas" must be an absolutely-positioned element with an area
coincident with the UA window or frame, "auto" overflow, no padding, and no
border. BODY can't fit this description. What's left?

By what mechanism does a background declaration 'reverse-inherit' in the
ancestry from BODY? By what rule does the declaration not apply to BODY
itself? From the draft, 'background-position': "With a value pair of '0%
0%', the upper left corner of the image is placed in the upper left corner
of the box that surrounds the content of the element (i.e., not the box that
surrounds the padding, border or margin)."[1] But when applied to BODY in
either of the 'big2' UAs, a background image positioned at 0% 0% is rendered
from the upper left corner of the UA window, not from the upper left of
BODY's content area -- UNLESS a border is also declared. If a border is also
declared, NN4.1 renders both the border and the image background of BODY
almost correctly. IE4, however, renders the border along the edge of the UA
window -- OUTSIDE of the scroll bar -- and still renders the background from
the upper left of the window. This is thoroughly discordant with the CSS
rendering model.

Netscape is leaning in the right direction. BODY should be rendered as a
block-level element in full accordance with CSS rendering conventions. A
background image should be positioned relative to the content area of the
element for which it is declared, unless declared with background-attachment
of 'fixed'.

So where does this leave the canvas? There should either be (1) some means
to declare a background for the canvas, or (2) when the background
reverse-inherits, the background-position should be coincident with the
background-position of BODY, or (3) only the background-color should
reverse-inherit, not the image.

I'm back to arguing for #1: a hypothetical top level 'canvas' element. Some
properties of this element -- at a minimum, background properties --  should
be accessible to stylesheets. For backward compatibility, the HTML
'bgcolor=' and 'background=' attributes of BODY could refer to the canvas.
Whether the canvas is accessed in CSS via the HTML element or by some other
means matters little as long as the mechanism is defined in the spec.

David Perrell

[1] http://www.w3.org/TR/WD-CSS2/colors.html#propdef-background-position

Received on Thursday, 18 December 1997 02:11:27 UTC