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, 2022 in CSS by Edureka
• 12,880 points
140 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, 2022 by Edureka
• 11,450 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, 2022 in CSS by Edureka
• 11,450 points
136 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, 2022 in CSS by Edureka
• 11,450 points
129 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, 2022 in CSS by Edureka
• 11,450 points
140 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, 2022 in CSS by Edureka
• 12,880 points
48 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
5,957 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,884 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
367 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, 2022 in CSS by Edureka
• 11,450 points
1,330 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, 2022 in CSS by Edureka
• 11,450 points
129 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP