The body tag selects the entire body of the html document. You need to give your box a id or class and then apply the CSS to that.

For example:

#box  {
  background-color: yellow;
  border: 1px solid #000000;
  width: 300px;
  height: 300px;
}
<div id="box"></div>
Answer from user7600596 on Stack Overflow
🌐
W3Schools
w3schools.com › css › css_border_color.asp
CSS Border Color
CSS Reference CSS Selectors CSS ... Color Values CSS Default Values CSS Browser Support ... The border-color property is used to set the color of the four borders....
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › Reference › Properties › border-color
border-color - CSS | MDN
2 weeks ago - The border-color shorthand CSS property sets the color of an element's border.
Discussions

HTML CSS color within border - Stack Overflow
I am trying to make a small yellow square of 300x300 pixels let's say with a black border. I use: body { background-color: yellow; border: 1px solid #000000; width: 300px; h... More on stackoverflow.com
🌐 stackoverflow.com
html - CSS default border color - Stack Overflow
Let we have the following html markup: and corresponding css styles: .parent{ bor... More on stackoverflow.com
🌐 stackoverflow.com
Creating different border colors?
I am trying to make my top left corner red, top right corner yellow, bottom left corner blue and bottom right corner green. I have been at this for 30 minutes and no luck lol. Here is my code and a snip of what it currently looks like More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
November 3, 2023
Why does changing the background-color of a <button> change its border and border radius and hover effects?
Buttons are a bit weird. They have a default styling that comes from the user-agent stylesheet (browser built in stylesheet) that is different from browser to browser. Most browsers completely remove the default styling when you create your own style, even if you’re just overriding one thing. The issue you’re facing is that there’s sometimes a second fallback that uses ”webkit-appearence: button;” which has a different styling. I remember this article from CSS tricks being a good read on how to normalize and style buttons More on reddit.com
🌐 r/css
25
5
December 26, 2024
🌐
W3Schools
w3schools.com › cssref › pr_border-color.php
CSS border-color property
❮ Previous Complete CSS Reference Next ❯ · Set a color for the border: div {border-color: coral;} Try it Yourself » · More "Try it Yourself" examples below. The border-color property sets the color of an element's four borders. This property ...
Find elsewhere
🌐
Tutorial Republic
tutorialrepublic.com › css-reference › css-border-color-property.php
CSS border-color Property - Tutorial Republic
HOME HTML5 CSS3 JAVASCRIPT JQUERY BOOTSTRAP5 v4.6 PHP7 SQL REFERENCES EXAMPLES FAQ SNIPPETS Online HTML Editor ... The border-color CSS property is a shorthand property for setting the individual border color properties i.e.
Top answer
1 of 8
4

You can't change the default. The default is whatever the browser defines it as.

If you want to inherit the value from the parent (as your mentioning the parent in the question implies), then you must explicitly inherit it.

.child {
    border-color: inherit;
}

You must also not use the shorthand border property with the color value omited, since that will reset the property to the default.

.child {
    border-color: inherit;
    border-width: 20px;
    border-style: solid;
}

You can also simply be explicit:

.child {
    border-color: green;
    border-width: 20px;
    border-style: solid;
}
2 of 8
3

Most of the currently accepted answer is inaccurate:

You can change the default border color: not by CSS, but in the user's graphic environment (system settings, usually available as desktop settings in OS).

You can omit the color value in border shorthand property. In CSS3 the border-color is then set to currentColor, which can also be specified explicitly.

border: 1px solid currentColor; /* CSS3 */

The currentColor is usually black by default system settings. In CSS2, you can also use other system values, see in the link above. These are deprecated, but still working in my Opera.

border: 1px solid ThreeDDarkShadow; /* CSS2 deprecated */

Now the color is gray in my environment. The CSS2 values are (quoting the link above):

ActiveBorder, ActiveCaption, AppWorkspace, Background, ButtonFace, ButtonHighlight, ButtonShadow, ButtonText, CaptionText, GrayText, Highlight, HighlightText, InactiveBorder, InactiveCaption, InactiveCaptionText, InfoBackground, InfoText, Menu, MenuText, Scrollbar, ThreeDDarkShadow, ThreeDFace, ThreeDHighlight, ThreeDLightShadow, ThreeDShadow, Window, WindowFrame, WindowText.

Note: currentColor is different from inherit (which will solve your problem as Quentin suggests) and there is no value keyword like default, auto or initial in border-color property. One might think that if you specify invalid or browser-unsupported color, the browser has to pick some color and if there is no way to infer that color, it logically picks the system color anyway since browsers don't stop output on syntax error. However, some browsers implement a mystical numerologic algorithm to infer colors from unknown strings. It doesn't apply in my Opera.

Check your system colors in the snippet

  div { float: left; margin: 5px; width: 125px; padding: 20px; border: 1px solid black; color: #800; text-shadow: 0 1px black;}
  .ActiveBorder { background-color: ActiveBorder; }
  .ActiveCaption { background-color: ActiveCaption; }
  .AppWorkspace { background-color: AppWorkspace; }
  .Background { background-color: Background; }
  .ButtonFace { background-color: ButtonFace; }
  .ButtonHighlight { background-color: ButtonHighlight; }
  .ButtonShadow { background-color: ButtonShadow; }
  .ButtonText { background-color: ButtonText; }
  .CaptionText { background-color: CaptionText; }
  .GrayText { background-color: GrayText; }
  .Highlight { background-color: Highlight; }
  .HighlightText { background-color: HighlightText; }
  .InactiveBorder { background-color: InactiveBorder; }
  .InactiveCaption { background-color: InactiveCaption; }
  .InactiveCaptionText { background-color: InactiveCaptionText; }
  .InfoBackground { background-color: InfoBackground; }
  .InfoText { background-color: InfoText; }
  .Menu { background-color: Menu; }
  .MenuText { background-color: MenuText; }
  .Scrollbar { background-color: Scrollbar; }
  .ThreeDDarkShadow { background-color: ThreeDDarkShadow; }
  .ThreeDFace { background-color: ThreeDFace; }
  .ThreeDHighlight { background-color: ThreeDHighlight; }
  .ThreeDLightShadow { background-color: ThreeDLightShadow; }
  .ThreeDShadow { background-color: ThreeDShadow; }
  .Window { background-color: Window; }
  .WindowFrame { background-color: WindowFrame; }
  .WindowText { background-color: WindowText; }
<div class="ActiveBorder">ActiveBorder</div>
<div class="ActiveCaption">ActiveCaption</div>
<div class="AppWorkspace">AppWorkspace</div>
<div class="Background">Background</div>
<div class="ButtonFace">ButtonFace</div>
<div class="ButtonHighlight">ButtonHighlight</div>
<div class="ButtonShadow">ButtonShadow</div>
<div class="ButtonText">ButtonText</div>
<div class="CaptionText">CaptionText</div>
<div class="GrayText">GrayText</div>
<div class="Highlight">Highlight</div>
<div class="HighlightText">HighlightText</div>
<div class="InactiveBorder">InactiveBorder</div>
<div class="InactiveCaption">InactiveCaption</div>
<div class="InactiveCaptionText">InactiveCaptionText</div>
<div class="InfoBackground">InfoBackground</div>
<div class="InfoText">InfoText</div>
<div class="Menu">Menu</div>
<div class="MenuText">MenuText</div>
<div class="Scrollbar">Scrollbar</div>
<div class="ThreeDDarkShadow">ThreeDDarkShadow</div>
<div class="ThreeDFace">ThreeDFace</div>
<div class="ThreeDHighlight">ThreeDHighlight</div>
<div class="ThreeDLightShadow">ThreeDLightShadow</div>
<div class="ThreeDShadow">ThreeDShadow</div>
<div class="ThreeDShadow">ThreeDShadow</div>
<div class="Window">Window</div>
<div class="WindowFrame">WindowFrame</div>
<div class="WindowText">WindowText</div>
🌐
TutorialsPoint
tutorialspoint.com › css › css_border-color.htm
CSS - border-color Property
CSS border-color property lets you set the color of an element's four borders. You can specify different colors for each border side based on the number of values provided. The border-style must be defined.
🌐
Bootstrap
getbootstrap.com › docs › 5.3 › utilities › borders
Borders · Bootstrap v5.3
That means anytime you use .border-success now, your computed color value is rgba(25, 135, 84, 1). The local CSS variable inside each .border-* class avoids inheritance issues so nested instances of the utilities don’t automatically have a modified alpha transparency.
🌐
Mimo
mimo.org › glossary › css › border-color
CSS Border Color: Customize Element Edges
The CSS border-color property defines the color of an element's border.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › Reference › Properties › border
border - CSS | MDN
2 weeks ago - border = <line-width> || <line-style> || <color> <line-width> = <length [0,∞]> | thin | medium | thick <line-style> = none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset
🌐
HubSpot
blog.hubspot.com › website › css-border
How to Create and Style Borders in CSS
February 23, 2023 - The CSS border-style property specifies what type of border to display. There are ten possible values you can use to set the border-style property. Let’s take a quick look at them below. ... The effect of the groove, ridge, inset, and outset values depends on the value set for the border-color property.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › Reference › Properties › border-inline-color
border-inline-color - CSS | MDN
1 month ago - The border-inline-color CSS property defines the color of the logical inline borders of an element, which maps to a physical border color depending on the element's writing mode, directionality, and text orientation. It corresponds to the border-top-color and border-bottom-color, or ...
🌐
GeeksforGeeks
geeksforgeeks.org › css › css-border-color-property
CSS border-color Property - GeeksforGeeks
September 17, 2024 - The CSS border-color property allows developers to define the color of an element's border, enhancing the visual design of a webpage.
🌐
Udacity
udacity.com › blog › 2021 › 03 › the-easy-basics-of-css-border-color.html
The Easy Basics of CSS Border Color | Udacity School of Programming
March 5, 2021 - The CSS Border Color property was created to allow the designer to implement a coloring for a boxed border. For example, a highlighted section of a selected menu item or a bright border around a special item on sale for the week.
🌐
TechOnTheNet
techonthenet.com › css › properties › border_color.php
CSS: border-color property
This CSS tutorial explains how to use the CSS property called border-color with syntax and examples. The CSS border-color property defines the color of the border of a box.
🌐
Quackit
quackit.com › css › properties › css_border-color.cfm
CSS border-color
CSS border-color - CSS property for setting the border color of a box.
🌐
freeCodeCamp
forum.freecodecamp.org › html-css
Creating different border colors? - HTML-CSS - The freeCodeCamp Forum
November 3, 2023 - I am trying to make my top left corner red, top right corner yellow, bottom left corner blue and bottom right corner green. I have been at this for 30 minutes and no luck lol. Here is my code and a snip of what it curren…