Border Color Property

Last updated: 2026-09-13

border-color Border Color Property

border-color sets the color of an element's border. It accepts every CSS color format, including color names, hex values, rgb(), rgba(), hsl(), and more. Used on its own, it only affects the border color, not the width or style.

Category
Initial Valuecurrentcolor
InheritedNo
Applies Toall
Animation Typecolor
CSS VersionCSS1
StatusStandard

📝 Syntax

border-color: <color>{1,4};

⚙️ Values

ValueTypeDescription
<color>TypeBorder color value
transparentKeywordTransparent border

▶ Example

Edit the code below and see the live result in the playground:

🌐 Browser Support

Browser ChromeChrome EdgeEdge FirefoxFirefox SafariSafari OperaOpera
border-color v1 v12 v1 v1 v1
Supported in all major browsers
Tip: border-color accepts 1 to 4 values so you can give each edge a different color, for example: border-color: red green blue orange.
Tip: Use transparent to create an invisible border, often to reserve space so adding a border on hover does not shift the layout.

❓ FAQ

QWhat is the default value of border-color?
AThe default is currentcolor, which means the border automatically uses the element's current text color (the value of the color property). So if you set only border-width and border-style and no color, the border follows the text color. To keep the border independent of the text, specify a color explicitly, e.g. border-color: #333;.
QHow do I give the four sides different colors?
Aborder-color accepts 1 to 4 values assigned clockwise from the top: one value colors all sides, two values map to top/bottom and left/right, three to top, left/right, and bottom, and four to top, right, bottom, left. For example, border-color: red green blue orange;. Or use per-side properties like border-top-color for precise control.
QWhich color formats does border-color support?
AAll CSS color formats: keywords (red, transparent), hex codes (#9b59b6, #f00), rgb()/rgba(), hsl()/hsla(), and currentcolor. rgba() creates semi-transparent borders, transparent is a common invisible placeholder, and hsla() lets you adjust alpha while keeping the hue.
QHow do I use a transparent border to prevent layout shift on hover?
AFirst reserve the space with border: 2px solid transparent;, then change only the color on hover, e.g. border-color: #3498db;. Because the border always exists, the element size never changes and the layout does not jump. This is the standard anti-shift trick for nav links and buttons.

📚 Related Tutorials

Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏