CSS border-left-color
Property
The border-left-color
property in CSS is used to set the color of the left border of an element. This property does not work unless a border-left-style
is defined.
1. Syntax
✅ The color can be specified using color names, HEX codes, RGB, RGBA, or HSL.
Value Options:
Value | Description |
---|---|
Color Name | red , blue , green , etc. |
Hex Code | #ff5733 , #000000 , etc. |
RGB | rgb(255, 0, 0) |
RGBA | rgba(255, 0, 0, 0.5) (with transparency) |
HSL | hsl(0, 100%, 50%) |
2. Example – Setting Left Border Color
✅ The left border will be 5px thick, solid, and blue.
3. Example – Using the border-left
Shorthand
✅ This is equivalent to:
4. Example – Transparent Left Border
✅ The left border exists but is invisible.
5. Example – Different Border Colors for Each Side
✅ Each side has a different color.
6. Removing the Left Border
✅ Removes the left border.
7. Border-Left-Color vs. Shorthand Border
border-left-color | Shorthand border-left |
---|---|
Only sets color | Sets width, style, and color |
border-left-color: red; | border-left: 2px solid red; |
✅ Use border-left
shorthand when setting width, style, and color together.
8. Best Practices
✔ Always define border-left-style
for the border to appear.
✔ Use border-left
shorthand when setting multiple properties.
✔ Use border-left: none;
to remove the left border.