rule, where the amount by which paragraphs overlap each other and
spill beyond the browser window is entirely dependent on the width of
the window itself -- and the wider the window, the worse the
situation becomes.
Figure 7-20. The dangers of document-wide negative-margin rules
Using negative
margins with block-level elements
such as these can quite obviously be dangerous and is rarely worth
the trouble -- but it can also be rewarding. It takes a good deal
add a background color, as shown in Figure 7-58:
H1 {padding: 10px 0.25em 3ex 3cm; background: silver;}
H2 {padding: 0.5em 2em; background: silver;}
Figure 7-58. Uneven padding with background colors
As Figure 7-58 demonstrates, the
background of an element extends into the
padding. As we discussed before, it also extends to the outer edge of
the border, but the background has to go through the padding before
it even gets to the border.
Let's say that you want to center a background image within its
element by using percentage values. That's easy enough:
BODY {background-image: url(bigyinyang.gif);
background-repeat: no-repeat;
background-position: 50% 50%;}
This causes the background image to be placed such that its center is
aligned with the center of its parent element, as demonstrated in
Figure 6-39. In other words, the percentage values
apply to both the element and the background image.
words, the value has to exist in order for normal, nonfloatingbehavior to be possible; without it, all elements would float in oneway or another.
Second, it's possible that you might want to override a certainstyle from an imported style sheet. Imagine thatyou're using a server-wide style sheet that floats images. Onone particular page, you don't want those images to float.Rather than writing a whole new style sheet, you could simply placeIMG {float:
browser should ignore the text because it isn't part of theBODY element, but this is never the case.) Thisproblem is illustrated in Figure 1-5.
Figure 1-5. Older browsers will literally display your style sheets
In order to combat thisproblem, it is recommended that you enclose your declarations in acomment tag. In the examplegiven here, the beginning of the comment tag appears right after theopening STYLE tag, and the end of the comment