vucibatina
vucibatina

Reputation: 107

Borders applying font color in CSS

As CSS beginner I noticed that if you do not declare border color in a shorthand form, but before that you declare font color, that color will apply to the former as well e.g.

#crazyElement {color:red; border:1px solid;}

both will be red. Moreover, if you declare font color for the body, each border without declared color in shorthand form will apply that color also.

Is this normal? Maybe it's nothing special, but as a novice I just wanted to check...

Upvotes: 5

Views: 1987

Answers (3)

Andrew
Andrew

Reputation: 13853

That is normal, and perfectly inline with the specification

If an element's border color is not specified with a border property, user agents must use the value of the element's 'color' property as the computed value for the border color.

via @BoltClock CSS3 Spec. and the currentColor which is how it is defined.

Upvotes: 10

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114417

Certain properties in CSS are automatically inherited.

Here's the list: http://www.w3.org/TR/CSS21/propidx.html

Upvotes: 0

Madara's Ghost
Madara's Ghost

Reputation: 174997

From the specs:

This property describes the foreground color of an element's text content. In addition it is used to provide a potential indirect value (currentColor) for any other properties that accept color values. If the ‘currentColor’ keyword is set on the ‘color’ property itself, it is treated as ‘color: inherit’.

So yes, it's normal.

Upvotes: 0

Related Questions