Sent by Jon Jensen on 12 November 2003 02:02
<snip>
When I read the CSS2 Reference (Section 8.5.4) I interpret it to mean
that the first and second lines in this test should have black borders.
Opera 6 agrees, but Explorer 5.2.3, Firebird 0.7 and Mozilla 1.4 don't;
neither does David Baron. I would have to assume that they're right and
I'm lost.
Is it possible that for border-color to appear in a stylesheet there are
only 5 acceptable forms 1) border-color-top: value; 2)
border-color-right: value; 3) border-color-left: value; 4)
border-color-bottom: value; 5) border-color: value value value value;
but NOT ALLOWED border-color: value; for all sides?
</snip>
Here is what's going on:
If you look at the CSS2 spec, they give the following example:
blockquote {
border: solid red;
border-left: double;
color: black;
}
In the above example, the color of the left border is black, while
the other borders are red. This is due to 'border-left' setting
the width, style, and color. Since the color value is not given by
the 'border-left' property, it will be taken from the 'color'
property. The fact that the 'color' property is set after the
'border-left' property is not relevant.
The same thing is happening here as in the ones you cited.
'border','border-top','border-right','border-bottom' and 'border-left' set
the values for width,style and color. That means they effectively erase any
previous declarations in the rule. So in the following rule, 'border'
overrides 'border-color' even though it does not explicitly set a color.
one {
border-color: red;
color: green;
border: medium solid;
}
Why then is it green? In the spec, the default border-color is the value of
the color property. Since there is no set border-color due to the 'border'
declaration, it then inherits 'color: green'. As explained in the citation
from the spec, where exactly the color property is set is irrelevant.
To answer the second part of your question, 'border-color: value' is valid
and will always work as long as it's not overridden later by a declaration
such as 'border: medium solid'. So swapping the order of the two will give
you a red border.
Jon
______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/