The border-top-color property sets the color of the border on the physical top side only.
01
Top Side
Physical color.
02
Longhand
Color only.
03
Color Formats
Hex, rgb, hsl.
04
currentcolor
Matches text.
05
Override
Recolor top only.
06
Classic CSS
Universal support.
Fundamentals
Definition and Usage
The border-top-color CSS property sets the color of the border on the physical top side of an element. It is a longhand of border-top and works alongside border-top-width and border-top-style.
Unlike logical properties such as border-block-start-color, border-top-color always targets the physical top edge — even in vertical writing modes. That makes it straightforward for section headers, card accent bars, and horizontal dividers.
💡
Beginner Tip
border-top-color only sets color. Pair it with a visible border width and style, or use border: 2px solid; plus this longhand to recolor only the top side.
Foundation
📝 Syntax
border-top-color accepts any valid CSS color value:
syntax.css
selector{border-top-color:color;}
Basic Example
border-top-color.css
div{border:2px solid;border-top-color:red;}
Syntax Rules
Accepts named colors, hex, rgb, hsl, currentcolor, and transparent.
Only affects the top border side; other sides keep their own colors.
You need a visible border width and style for the color to appear.
Always affects the physical top side, regardless of direction or writing-mode.
Default is currentcolor, matching the element’s text color.
Cheat Sheet
⚡ Quick Reference
Question
Answer
Initial value
currentcolor
Applies to
Top border color only
Inherited
No
Animatable
Yes, as a color
Common use
Section dividers, card accents, recoloring one side
Defaults
Default Value
The default value of border-top-color is currentcolor. The top border uses the element’s text color unless you set a different color explicitly.
Reference
💎 Property Values
Value
Example
Meaning
Named color
border-top-color: green;
Uses a CSS color keyword on the top side
Hex
border-top-color: #2563eb;
Hexadecimal color on the physical top side
HSL
border-top-color: hsl(142, 71%, 45%);
HSL functional notation
currentcolor
border-top-color: currentcolor;
Matches the element’s text color
transparent
border-top-color: transparent;
Makes the top border invisible
green
#2563eb
hsl
Common Value Types
greennamed color
#2563ebhex value
currentcolormatches text
Scope
Top Border Color and Writing Modes
border-top-color always colors the physical top edge. Vertical writing modes do not move the border — compare with border-block-start-color when block-start should follow the writing mode.
Horizontal (writing-mode: horizontal-tb)
Red top border on the top edge
topleftrightbottom
Vertical (writing-mode: vertical-rl)
Top border color still on the physical top
topleftrightbottom
Compare
border-top-color vs related properties
Property
Targets
Best for
border-top-color
Color on the physical top side only
Top accent bars, section dividers, recoloring one side
border-top
Width, style, and color on the top side
Setting the full top border in one rule
border-block-start-color
Color on the block-start side (writing-mode-aware)
Header accents that follow vertical writing modes
border-top-style
Style on the physical top side only
Changing solid, dashed, or dotted on the top edge
Preview
👀 Live Preview
A box with a blue top border on a gray frame:
Blue border on the physical top edge.
Uses border: 3px solid #cbd5e1; and border-top-color: #2563eb;.
Hands-On
Examples Gallery
Try border-top-color with named colors, hex values, currentcolor, and vertical writing.
📚 Basic Top Border Colors
Color only the physical top border side.
Example 1 — Red Top Border Color
Change the top border color to red on a box with a visible border, matching the reference tutorial.
border-top-color-red.html
<style>div{border:2px solid;border-top-color:red;padding:10px;}</style><div>
This div has a red top border.
</div>
currentcolor is the default value. Here it makes the top border purple to match the text while other sides stay gray.
Example 4 — border-top-color in Vertical Writing
In vertical writing, border-top-color stays on the physical top — unlike border-block-start-color.
border-top-color-vertical.html
<style>.vertical-box{writing-mode:vertical-rl;display:inline-block;border:3px solid #cbd5e1;border-top-color:#059669;padding:0.75rem 1rem;background:#ecfdf5;}</style><divclass="vertical-box">
Top border color stays on the physical top
</div>
Vertical writing changes text flow but not the physical top edge. For a block-start accent that follows the writing mode, use border-block-start-color instead.
🧠 How border-top-color Works
1
Border must be visible
A width and style on the top side create a border to color.
Setup
2
Color longhand applies
border-top-color sets the physical top edge color only.
Color
3
Other sides stay unchanged
Right, bottom, and left borders keep their own colors unless you override them.
Scope
=
🎨
Colored top border
Only the physical top edge shows your chosen color.
Compatibility
Modern Browser Support
The border-top-color property is supported in all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera.
✓ Baseline · Modern browsers
Physical top border colors in every browser
Chrome, Edge, Firefox, Safari, and Opera have supported border-top-color since the earliest CSS versions.
99%Modern browser support
Google Chrome87+ · Desktop & Mobile
Full support
Mozilla Firefox66+ · Desktop & Mobile
Full support
Apple Safari14.1+ · macOS & iOS
Full support
Microsoft Edge87+ · All versions
Full support
Opera73+ · Modern versions
Full support
border-top-color property99% supported
Bottom line: Use border-top-color for reliable top-side accent colors in any modern browser.
Wrap Up
Conclusion
The border-top-color property controls the color of the physical top border. Use it for section dividers, card accent bars, and highlights where the border should stay on the top edge.
Pair it with border-top-width and border-top-style, or use the border-top shorthand when you want width, style, and color together.
Set border width and style alongside color for visible top borders
Use currentcolor when the top border should match text
Use border-top-color for section headers, card accent bars, and horizontal dividers
Override one side after a border shorthand to recolor only the top
Use border-block-start-color when the accent must follow vertical writing modes
❌ Don’t
Set color alone without a visible border width and style
Expect border-top-color to move to the side in vertical writing modes
Mix conflicting physical and logical color rules on the same element
Use border-top-color when the design needs a block-start accent in vertical writing
Forget that the shorthand sets all sides before your longhand override
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about border-top-color
Use these points when coloring physical top borders.
5
Core concepts
🎨01
Top color only
Physical side.
Purpose
⚡02
currentcolor
Default.
Default
🔀03
red
Named color.
Values
🌐04
Fixed top
Not logical.
Physical
🛠05
Needs width
Color longhand.
Usage
❓ Frequently Asked Questions
The border-top-color property sets the color of the border on the physical top edge of an element only.
The initial value is currentcolor, which uses the element's text color for the top border.
border-top-color always targets the physical top edge, regardless of text direction or writing mode.
border-top-color only sets color. You also need a visible border width and style, or use a shorthand like border: 2px solid plus this longhand.
border-top-color is fixed to the physical top edge. border-block-start-color follows the writing mode, so in vertical writing it may appear on the side instead of the top.