The border-color property sets the color of an element’s borders. Use one color for all sides or up to four values to color top, right, bottom, and left separately.
01
Border Colors
Color all four sides.
02
One Value
Same color everywhere.
03
Four Values
Top, right, bottom, left.
04
Color Formats
Named, hex, rgb, hsl.
05
currentColor
Match text color.
06
With Style
Needs visible borders.
Fundamentals
Definition and Usage
The border-color CSS property controls the color of an element’s border lines. It works on any element that has a visible border style and width. You can apply a uniform color across all four sides or assign different colors to each side for more expressive layouts.
Customizing border color helps elements stand out, match your brand palette, or create subtle separation between sections. It is often used together with border-width and border-style, or through the convenient border shorthand.
💡
Beginner Tip
border-color alone does not draw a border. Pair it with a style like solid and a width greater than 0, or use border: 2px solid red; in one rule.
Foundation
📝 Syntax
The border-color property accepts one to four color values:
syntax.css
/* one color for all sides */selector{border-color:color;}/* top | right | bottom | left */selector{border-color:top right bottom left;}
Basic Example
border-color.css
.box{border:2px solid red;padding:10px;}
Syntax Rules
One value applies the same color to all four sides.
Two values set vertical sides first, then horizontal sides.
Three values set top, horizontal sides, then bottom.
Four values follow top, right, bottom, left order (clockwise).
Any valid CSS color is allowed, including currentColor and transparent.
Cheat Sheet
⚡ Quick Reference
Question
Answer
Initial value
currentColor
Applies to
All four border sides
Inherited
No
Animatable
Yes, as a color
Common use
Cards, buttons, outlines, and highlighted boxes
Defaults
Default Value
The default value of border-color is currentColor. That means the border uses the element’s text color unless you set a different color explicitly.
Reference
💎 Property Values
border-color accepts any standard CSS color value.
Value
Example
Meaning
Named color
border-color: red;
Uses a CSS color keyword
Hex
border-color: #ff5733;
Uses a hexadecimal color
RGB
border-color: rgb(255, 87, 51);
Uses an RGB color function
HSL
border-color: hsl(9, 100%, 60%);
Uses an HSL color function
currentColor
border-color: currentColor;
Uses the element’s text color
transparent
border-color: transparent;
Makes the border invisible while keeping layout space
red#ff5733rgb()hsl()
Multi-Value Syntax
blue1 value — all sides
blue red2 values — vertical | horizontal
blue red green3 values — top | sides | bottom
red green blue yellow4 values — top | right | bottom | left
Scope
One Color vs Different Side Colors
Use a single value when every side should match. Use four values when each physical side needs its own color.
Uniform color
Red on every side
Four different colors
Top red, right green, bottom blue, left yellow
Compare
border-color vs related properties
Property
Targets
Best for
border-color
All four physical sides
Simple boxes with one or more side colors
border
Width, style, and color together
Quick borders in one declaration
border-top-color, etc.
One physical side only
Changing a single edge color
border-block-color
Logical block-start and block-end
Writing-mode-aware vertical borders
Preview
👀 Live Preview
A box with a uniform red border on all sides:
This box has a red border.
Uses border: 3px solid #dc2626; and padding: 1rem;.
Hands-On
Examples Gallery
Try border-color with a uniform red border, four side colors, hex values, and currentColor.
📚 Basic Border Colors
Start with one color on all sides, then try a different color on each edge.
Example 1 — Uniform Red Border
Set a uniform border color of red for all sides of a div, using the border shorthand.
border-color-red.html
<style>.box{border:2px solid red;padding:10px;}</style><divclass="box">
This box has a red border.
</div>
The border shorthand sets width, style, and color together. Red applies to all four sides at once.
Example 2 — Different Color on Each Side
Set four border colors using top, right, bottom, and left order.
border-color-multi.html
<style>.box{border-width:2px;border-style:solid;border-color:red green blue yellow;padding:10px;}</style><divclass="box">
This box has different colors for each border.
</div>
currentColor is the default border color. Setting it explicitly keeps the border synced when text color changes in themes or states.
🧠 How border-color Works
1
You set border width and style
Borders need a visible style and thickness before color can appear on screen.
Prerequisite
2
You choose one or more colors
Apply a single color or up to four values with border-color.
CSS rule
3
The browser paints each side
Each border edge uses the matching color from your value list.
Rendering
=
🎨
Colored borders
Your element gets visible, theme-ready borders that help structure the layout.
Compatibility
Universal Browser Support
The border-color property is supported in all major browsers, including Chrome, Firefox, Safari, Edge, Opera, and Internet Explorer. It is one of the most reliable CSS properties.
✓ Baseline · All browsers
Reliable border colors on every platform
Chrome, Firefox, Safari, Edge, and Opera all support border-color consistently.
100%Universal support
Google ChromeAll versions
Full support
Mozilla FirefoxAll versions
Full support
Apple SafariAll versions
Full support
Microsoft EdgeAll versions
Full support
OperaAll versions
Full support
border-color property100% supported
Bottom line: Use border-color freely in any project. It works consistently across all browsers.
Wrap Up
Conclusion
The border-color property is a versatile CSS tool for customizing border appearance. Whether you need one matching color or a unique color on each side, it gives you precise control over how elements are outlined on the page.
Experiment with named colors, hex values, and multi-value syntax to create borders that fit your design theme and improve visual hierarchy.
Use the border shorthand for simple one-line borders
Pair border-color with a visible border-style
Use currentColor when borders should match text
Check contrast between border and background colors
Use side longhands when only one edge needs a different color
❌ Don’t
Expect color alone to show a border without width and style
Use very low-contrast border colors on important UI controls
Forget the top-right-bottom-left order with four values
Rely on physical side colors when logical properties fit RTL layouts better
Overuse rainbow borders without a clear design purpose
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about border-color
Use these points when styling borders on your next layout.
5
Core concepts
🎨01
Border Color
Colors all four sides.
Purpose
⚡02
currentColor
Default value.
Default
🖌03
1 to 4 Values
Per-side control.
Syntax
🖼️04
Any CSS Color
Named, hex, rgb, hsl.
Values
🛠05
Needs Style
Width + style required.
Usage
❓ Frequently Asked Questions
The border-color property sets the color of an element's borders. You can apply one color to all four sides or use up to four values for top, right, bottom, and left.
The initial value is currentColor, which uses the element's text color for the border.
border-color only sets color. You also need a visible border-style such as solid and a border-width greater than zero, or use the border shorthand.
Yes. Use four values in top, right, bottom, left order — for example, border-color: red green blue yellow;
border-color sets colors on all four physical sides. border-block-color targets only the logical block axis sides and adapts when writing mode changes.