CSS Reference ยท Borders, Outlines and Shadows
The border-color property
Reference for the CSS border-color property: set border colors with one to four values, use currentcolor and transparent, and mix with other properties.
The border-color property sets the color of an element's borders. It is a shorthand for the four side colors (border-top-color and the rest) and takes one to four values.
If you do not set it, borders use the element's text color (currentcolor). That makes it easy to build components whose borders follow the text, for example a button that changes both on hover by changing color alone.
CSS
.input { border: 2px solid; border-color: #94a3b8 #94a3b8 #475569; }
Try it
Syntax
CSS
border-color: <color>{1,4}
- Initial value:
currentcolor - Applies to: all elements
- Inherited: no
- Animatable: yes, as a color
- Computed value: the computed color for each side
Values
| Value | Description |
|---|---|
<color> |
Any color value: keyword, hex, rgb(), oklch(), and so on. Alpha is allowed. |
currentcolor |
The element's color. This is the default. |
transparent |
A fully transparent border. It still takes up space, and the background shows through it (see below). |
| One value | All four sides. |
| Two values | Top and bottom, then left and right. |
| Three values | Top, then left and right, then bottom. |
| Four values | Top, right, bottom, left (clockwise). |
Usage notes
- Needs a style to show. The color only matters when
border-styleis notnoneorhidden. - Transparent borders still paint the background under them. By default the background extends under the border (
background-clip: border-box), so a transparent border shows the element's background color or image. Setbackground-cliptopadding-boxif you want the gap to be see-through. - A reliable spacing trick. Reserve space for a border that appears on hover by giving the element
border: 2px solid transparentand changing only the color. Layout never jumps. - Triangles and corners. Different colors on adjacent sides meet at a diagonal. This was once used to draw CSS triangles with a zero-size box; today clip-path or SVG is clearer.
- Hover transitions work well because the color is animatable. Add
transition: border-color 0.2s. - Contrast. Borders that identify controls should have enough contrast with the background, commonly at least 3:1.
- Forced colors mode replaces border colors with system colors, which is usually helpful.
Browser support
Supported in every browser.
Related
borderโ the shorthandborder-width,border-stylecolorโ the source ofcurrentcoloroutline-colorโ the outline equivalent- Lessons: Borders, Colors