P {border-style: solid; border-width: thick;border-color: black rgb(25%,25%,25%) #808080 silver;}Figure 7-43 shows us varying shades of gray forborders. Thanks to the grayscale nature of this book, I've beensticking mostly to shades of gray, but any color could be used. Ifyou wanted an H1 with a red, green, blue, andyellow border, it's this easy:
H1 {border-style: solid; border-color: red green blue yellow;}brevity introduces a few limitations. Before we worry about that,let's see how border is used. If you wantall H1 elements to have a thick, silver border,it's very simple. This declaration would be displayed as shownin Figure 7-49:H1 {border: thick silver solid;}The drawback with border is that you can onlydefine "global" styles, widths, and colors. In otherwords, the values you supply for border will apply padding. Thus, the following two statements would have the sameeffect, as depicted in Figure 7-34:
P.new1 {border-style: solid dashed none;}P.new2 {border-style: solid dashed none dashed;}
In case you're wondering, under CSS1, there is no way todirectly set the style for only a single side using something likeborder-top-style, since no such property exists inCSS1 (although that property, and others like it, were introduced in
Now let us consider the cases where two of these three properties areset to auto. If both the margins are set toauto, then they are set to equal lengths, thuscentering the element within its parent, as you can see from Figure 8-14:
P {width: 100px; margin-left: auto; margin-right: auto;}<DIV STYLE="width: 100px;"><P>This paragraph is contained within a DIV with a width of 100 pixels,so its padding will still be 10% of the width of the paragraph's parent.There will, therefore, be half as much padding on this paragraph as thaton the first paragraph.</P>
We've seen this before, of course -- in Section 7.3, "Margins", in case you don't remember -- butit's worth reviewing again, just to see how it operates.