Previous Message
Next Message

RE: [css-d] What level of support for background-image to <HTML> element?

Sent by Eric A. Meyer on 11 August 2003 21:09


At 8:57 -0600 8/11/03, Michael Sauers wrote:

>There are no spec-based properties to do this that I'm
>aware of since <html> is the root element. Anything like background
>will/should appear as a property of the body and/or one of it's children.
>(Someone please feel free to correct me if I'm wrong.)

    Okay, I'll correct you.  It is quite acceptable, from the 
specification point of view, to style the 'html' element.  In fact, 
any element is up for styling, including the 'head' and its 
constituent elements:  see 
<http://www.meyerweb.com/eric/css/discuss/examples/all-shown.html>. 
You'll get at least some results in Gecko-based browsers, IE5/Mac, 
Opera 7, and Safari 1.0, plus maybe other KHTML-based browsers (I 
forget now), so ignore the "For Gecko only?" question.  In IE5/Mac 
you only see the element boxes for elements like 'title', not the 
content.
    Anyway, IE/Win has traditionally ignored the 'html' element as 
something that can be styled, but in IE6's standards mode, this is no 
longer the case (cf. 
<http://msdn.microsoft.com/workshop/author/css/overview/CSSEnhancement 
s.asp>).  You can see this in the above-mentioned "all-shown" test 
case, where the silver background is the 'html' element and the white 
bordered element is 'body'.
    The traditional behavior of the 'body' background covering the 
entire viewport isn't actually supportable in the CSS model, so 
special wording was required to allow such behavior in HTML documents 
only; see <http://www.w3.org/TR/CSS21/colors.html#q2>.  It's the only 
example of "upwards inheritance" in the whole of CSS, so far as I can 
recall, and it's a legacy behavior that does not carry over to XML-- 
including, in theory, XHTML.
    Practically speaking, the ability to style both 'html' and 'body' 
can allow an author to put two separate background images in the 
document, assuming the 'body' has no padding or margins.  For example:

    html {background: white url(hand1.jpg) top right no-repeat;}
    body {background: transparent url(hand2.jpg) top left no-repeat;
      padding: 0; margin: 0;}

Note that I explicitly made the 'body' background transparent, so the 
background of the parent 'html' could, to use the phrasing of the 
specification, "shine through."  NN4.x authors beware, since 
'transparent' is often interpreted as being black (for reasons much 
too tedious to go into here).

--
Eric A. Meyer (http://www.meyerweb.com/eric/), List Chaperone
"CSS is much too interesting and elegant to be not taken seriously."
   -- Martina Kosloff (http://www.mako4css.com/)
______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread: