Usage of border-left-color property in CSS

The border-left-color property in CSS is used to set the color of an element's left border. This property only works when a left border is already defined using the border-left-style or border property.

Syntax

border-left-color: color | transparent | initial | inherit;

Parameters

Value Description
color Sets the left border color (hex, rgb, color name)
transparent Makes the left border transparent
initial Sets to default value
inherit Inherits from parent element

Example

<!DOCTYPE html>
<html>
<head>
    <style>
        p.demo {
            border: 4px solid;
            border-left-color: #FF0000;
            padding: 10px;
        }
        
        .example-box {
            border: 3px solid black;
            border-left-color: blue;
            padding: 15px;
            margin: 10px 0;
        }
    </style>
</head>
<body>
    <p class="demo">
        Example showing border left color property with red left border
    </p>
    
    <div class="example-box">
        This div has a blue left border while other borders remain black
    </div>
</body>
</html>

Multiple Color Values Example

<!DOCTYPE html>
<html>
<head>
    <style>
        .color-examples div {
            border: 5px solid;
            margin: 10px 0;
            padding: 10px;
        }
        
        .hex-color {
            border-left-color: #00FF00;
        }
        
        .rgb-color {
            border-left-color: rgb(255, 165, 0);
        }
        
        .named-color {
            border-left-color: purple;
        }
        
        .transparent-border {
            border-left-color: transparent;
        }
    </style>
</head>
<body>
    <div class="color-examples">
        <div class="hex-color">Hex color: #00FF00 (Green)</div>
        <div class="rgb-color">RGB color: rgb(255, 165, 0) (Orange)</div>
        <div class="named-color">Named color: purple</div>
        <div class="transparent-border">Transparent left border</div>
    </div>
</body>
</html>

Key Points

  • The border-left-color property only affects the left border color
  • A border style must be defined first using border-left-style or border
  • Supports all CSS color formats: hex, RGB, HSL, and named colors
  • Default value is the current text color of the element

Browser Compatibility

The border-left-color property is supported by all modern browsers including Chrome, Firefox, Safari, Edge, and Internet Explorer 4.0+.

Conclusion

The border-left-color property provides precise control over left border styling. It's essential to define a border style first, and the property accepts various color formats for flexible design options.

Updated on: 2026-03-15T23:18:59+05:30

71 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements