Book HomeCascading Style Sheets: The Definitive GuideSearch this book Wednesday 28th of June 2017 07:18:46 AM

10.6. Borders

In CSS1, there are quite a few properties devoted to setting borders around element boxes, such as border-top-width and border-color, not to mention border itself. CSS2 adds a even more border properties, most of which are aimed at giving the author even more specific control of the borders. Before, it was difficult to set a :lang

On a completely different note isthe pseudo-class :lang, which is used to applystyles to elements with matching languages. Let's say you wantall paragraphs in English to be black on white, and all paragraphs in specific color or style for a given side of the border, except through properties like border-left, and that could require more than one value. The new CSS2 properties address this, and their names are pretty self-explanatory:


Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.

should be affected by the property, although not all user agents cando this correctly. Also,background-color is not inherited. Its defaultvalue istransparent,which makes sense; if an element doesn't have a defined color,then its background should be transparent so that the background ofits ancestor elements will be visible. Imagine for a moment that the properties: if you omit a value, the default will be filled in automatically. This can have unintended effects. Consider the following:

H4 {border-style: dashed solid double;}
H4 {border: medium green;}

This will result in H4 elements having no border at all, because the lack of a border-style in the second rule means that the default value of none will be used. As we've seen, that will turn the border off altogether. For example, you might want a color to be exactly 25.5% red, 40% green, and 98.6% blue. Not a problem:

H2 {color: rgb(25.5%,40%,98.6%);}

Actually, there is a problem. Some user agents may not recognize decimal values, and still others could interpret them as if the decimal wasn't there, which would lead them to think the preceding value is actually rgb(255%,40%,986%). In that case, assuming the user agent behaves correctly, the out-of-range values will be