Why is the CSS border-color inheriting the color property

0 votes

Is it normal that a border color would be inherited from font's color property? I was surprised to find that:

div
{
 border: 4px solid;
 color: red;
 height: 100px;
 width: 100px;
}

gives me a div with a red border. Usually not specifying a color will default to black. What is this odd inheritance?

May 31 in CSS by Edureka
• 9,940 points
12 views

1 answer to this question.

0 votes
An element in CSS can have two "primary" colours: a foreground colour defined by the colour property and a background colour specified by the background-color property. Many other properties accept a colour value, but having black as the initial colour value would be arbitrary, hence properties that accept a colour value default to the computed foreground colour.

Of course, if the foreground colour is black, this will result in a black border, but only then. And the text colour is only black to begin with because that is what the default UA stylesheets do; CSS does not indicate anywhere that the initial value should be black, simply that it is UA-dependent (CSS1, CSS2.1, CSS Color 3).
answered Jun 10 by Edureka
• 9,540 points

Related Questions In CSS

0 votes
1 answer

What is the difference between CSS and SCSS?

CSS: Cascading Style Sheets (CSS) is a ...READ MORE

answered Jun 17 in CSS by Edureka
• 9,540 points
18 views
0 votes
1 answer

What is the css / html `root` element?

The:root CSS pseudo-class corresponds to the root ...READ MORE

answered Jun 28 in CSS by Edureka
• 9,540 points
17 views
0 votes
1 answer

when declaring css styles, what is the meaning of .classA.classB (two class names with a dot in the middle and no space)

The first example (space-separated classes) is a ...READ MORE

answered Jun 28 in CSS by Edureka
• 9,540 points
31 views
0 votes
0 answers

What are good uses of the css `content` property?

Because CSS is for display and not ...READ MORE

Jul 18 in CSS by Edureka
• 9,940 points
11 views
0 votes
2 answers

Define a SQL query? What is the difference between SELECT and UPDATE Query? How do you use SQL in SAS?

HI.. SQL is Structured Query Language, which is ...READ MORE

answered Aug 8, 2020 in PHP by anonymous
4,741 views
0 votes
1 answer

Using/Handling colon inside a JSF generated HTML element ID in CSS selector

Yes, you can.  Just Backslash (\) the colon.  Like ...READ MORE

answered Nov 14, 2018 in Others by DataKing99
• 8,240 points
1,703 views
0 votes
1 answer

What is a css selector and where is it used?

CSS Selector is a combination of element ...READ MORE

answered Nov 21, 2018 in Data Analytics by Kalgi
• 52,350 points
280 views
0 votes
1 answer

CSS: Set a background color which is 50% of the width of the window

You can make a hard distinction instead ...READ MORE

answered Jun 28 in CSS by Edureka
• 9,540 points
47 views
0 votes
1 answer

What is the proper way to display a logo with CSS?

An <img> element is the proper way ...READ MORE

answered Jun 10 in CSS by Edureka
• 9,540 points
30 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP