When you move the body element on a particular page in Chrome (testing v23) using position: relative; top: 100px; as example, the background is still applied to the whole viewport.
Is this a Chrome bug or could anyone explain the behavior / supply a flexible solution?
This is actually expected behavior for all browsers: while the
bodyelement is indeed being offset 100 pixels from the top, the background itself is being seamlessly propagated to the viewport as described in the first part of this answer. It’s probably a holdover from the era of HTML presentational attributes, where setting background attributes onbodyallowed the background to be propagated to the viewport, giving an appearance of applying a background to the whole page.If you want to restrict the background to only the
bodyelement, simply givehtmla background color that is anything other thantransparent, or give it a background image. The viewport will then use the background ofhtmlinstead.