CSS border-left-color Property

The border-left-color property sets the color of an element's left border.

It accepts any valid CSS color value, including named colors, hexadecimal colors, RGB, HSL, transparency, and modern color functions. The property changes only the border color, leaving its width and style unchanged. Because it targets a physical edge, the color always applies to the left border regardless of writing direction.

border-left-color Syntax

The property accepts a single CSS color value.

selector {
  border-left-color: #1769aa;
}

Named Color

.panel {
  border-left-color: blue;
}

Hexadecimal Color

.panel {
  border-left-color: #1769aa;
}

RGB Color

.panel {
  border-left-color: rgb(23 105 170);
}

HSL Color

.panel {
  border-left-color: hsl(207 76% 38%);
}

Transparent Color

.panel {
  border-left-color: transparent;
}

Current Text Color

.panel {
  border-left-color: currentcolor;
}

CSS Custom Property

.panel {
  border-left-color: var(--accent-color);
}

CSS-Wide Keywords

.inherited {
  border-left-color: inherit;
}
.reset {
  border-left-color: initial;
}
.unset {
  border-left-color: unset;
}
.reverted {
  border-left-color: revert;
}
.layer-reverted {
  border-left-color: revert-layer;
}

Only one color value is accepted. Multiple colors separated by spaces are invalid for this longhand property.

Property Values

The border-left-color property accepts the standard CSS <color> data type and CSS-wide keywords.

Value Description
Named color A predefined CSS color name such as red, blue, or green.
Hexadecimal A hexadecimal color such as #1769aa or #f00.
rgb() A color defined using red, green, and blue channels.
hsl() A color defined using hue, saturation, and lightness.
hwb() A color defined using hue, whiteness, and blackness.
lab(), lch() Colors defined using perceptual color spaces.
oklab(), oklch() Colors defined using modern perceptual color spaces.
color() A color defined in a supported color space.
color-mix() A color created by mixing other colors.
transparent A fully transparent color.
currentcolor Uses the element's computed text color.
inherit Inherits the computed border color from the parent.
initial Resets the property to currentcolor.
unset Resets the property to currentcolor because it is not inherited.
revert Reverts the property according to cascade origin rules.
revert-layer Reverts the property according to cascade layer rules.

Property Characteristics

Characteristic Value
Initial value currentcolor
Inherited No
Applies to Elements that support border properties
Computed value Computed color
Animation type By computed color
Percentages Not accepted as a standalone border color; percentages may appear inside supported color functions
Property type Longhand
Physical edge Left

The property controls only the color. The left border's width and style are determined separately.

How It Works

The browser applies the specified color to the physical left border when that border has a visible style and nonzero width.

Step 1: Set a Color

.panel {
  border-left-color: #1769aa;
}

No border appears if the left border style remains at its initial value of none.

Step 2: Add a Border Style

.panel {
  border-left-style: solid;
  border-left-color: #1769aa;
}

The border becomes visible using its initial medium width.

Step 3: Set a Width

.panel {
  border-left-width: 5px;
  border-left-style: solid;
  border-left-color: #1769aa;
}

The result is a 5-pixel solid blue left border.

Step 4: Change Only the Color

.panel {
  border-left: 5px solid #1769aa;
  border-left-color: #27ae60;
}

The border becomes green without changing its thickness or style.

Step 5: Use a Shorthand

.panel {
  border-left: 5px solid #27ae60;
}

The shorthand sets all three components in one declaration.

Use border-left-color when the width and style are already defined and only the color needs to change.

CSS Color Formats

The property supports CSS color formats recognized by the browser.

Named Colors

.panel {
  border-left: 5px solid;
  border-left-color: royalblue;
}

Three-Digit Hexadecimal

.panel {
  border-left: 5px solid;
  border-left-color: #f00;
}

Six-Digit Hexadecimal

.panel {
  border-left: 5px solid;
  border-left-color: #1769aa;
}

Eight-Digit Hexadecimal

.panel {
  border-left: 5px solid;
  border-left-color: #1769aa80;
}

The final two hexadecimal digits specify the alpha channel.

RGB

.panel {
  border-left: 5px solid;
  border-left-color: rgb(23 105 170);
}

RGB with Alpha

.panel {
  border-left: 5px solid;
  border-left-color: rgb(23 105 170 / 50%);
}

HSL

.panel {
  border-left: 5px solid;
  border-left-color: hsl(207 76% 38%);
}

HSL with Alpha

.panel {
  border-left: 5px solid;
  border-left-color: hsl(207 76% 38% / 50%);
}

HWB

.panel {
  border-left: 5px solid;
  border-left-color: hwb(207 9% 33%);
}

OKLCH

.panel {
  border-left: 5px solid;
  border-left-color: oklch(55% 0.15 250);
}

Color Mixing

.panel {
  border-left: 5px solid;
  border-left-color: color-mix(in srgb, blue 70%, white);
}

Modern color functions provide additional control over color spaces and mixing. Check compatibility when supporting older browsers.

Using currentcolor

The currentcolor keyword uses the element's computed color value.

Basic Example

.panel {
  color: #1769aa;
  border-left: 5px solid;
  border-left-color: currentcolor;
}

The text and left border use the same color.

Implicit currentcolor

.panel {
  color: #1769aa;
  border-left: 5px solid;
}

Because the border color is omitted, it defaults to currentcolor.

Inherited Text Color

.theme {
  color: #27ae60;
}
.theme .panel {
  border-left: 5px solid currentcolor;
}

The panel uses the inherited green text color unless another color declaration overrides it.

Changing Text and Border Together

.panel {
  color: #1769aa;
  border-left: 5px solid currentcolor;
}
.panel:hover {
  color: #c0392b;
}

When the element is hovered, both its text and border become red.

Using initial

.panel {
  border-left: 5px solid #1769aa;
  border-left-color: initial;
}

The border color resets to currentcolor.

The border color property itself is not inherited, but currentcolor can reflect an inherited text color.

Transparent and Semi-Transparent Colors

Transparent border colors allow the left border to retain its width without displaying an opaque line.

Fully Transparent Border

.panel {
  border-left: 8px solid transparent;
}

The border remains part of the element's box but is invisible.

Semi-Transparent RGB

.panel {
  border-left: 8px solid rgb(23 105 170 / 50%);
}

The border is drawn at 50% opacity.

Semi-Transparent HSL

.panel {
  border-left: 8px solid hsl(207 76% 38% / 40%);
}

Hexadecimal Alpha

.panel {
  border-left: 8px solid #1769aa80;
}

Reveal a Reserved Border

.panel {
  border-left: 8px solid transparent;
}
.panel:hover {
  border-left-color: #1769aa;
}

The border becomes visible without changing its width.

Transparent vs. none

.transparent-panel {
  border-left: 8px solid transparent;
}
.no-border-panel {
  border-left: none;
}

The transparent border occupies space, while the none style produces a computed border width of zero.

Transparent borders are useful when an interactive state should appear without changing the element's dimensions.

Border Visibility

A border color alone does not make a border visible.

Color Without a Style

.panel {
  border-left-color: #1769aa;
}

No border appears because the default border style is none.

Visible Solid Border

.panel {
  border-left: 5px solid #1769aa;
}

Style none

.panel {
  border-left-width: 5px;
  border-left-style: none;
  border-left-color: #1769aa;
}

The border is not drawn, and its computed width becomes zero.

Style hidden

.panel {
  border-left-width: 5px;
  border-left-style: hidden;
  border-left-color: #1769aa;
}

The border is not drawn. The hidden style also has special behavior when resolving collapsed table border conflicts.

Zero Width

.panel {
  border-left: 0 solid #1769aa;
}

The border has no visible thickness.

Transparent Color

.panel {
  border-left: 5px solid transparent;
}

The border occupies space but remains invisible.

When a colored border does not appear, check the border style, width, transparency, and any border-image settings.

Border Width and Style

The border-left-color property works with the width and style properties that control the same physical edge.

Set All Three Components

.panel {
  border-left-width: 5px;
  border-left-style: solid;
  border-left-color: #1769aa;
}

Equivalent Shorthand

.panel {
  border-left: 5px solid #1769aa;
}

Change the Color Only

.panel {
  border-left: 5px solid #1769aa;
  border-left-color: #27ae60;
}

Change the Style Only

.panel {
  border-left: 5px solid #1769aa;
  border-left-style: dashed;
}

Change the Width Only

.panel {
  border-left: 5px solid #1769aa;
  border-left-width: 10px;
}

Color with a Dotted Border

.panel {
  border-left-width: 5px;
  border-left-style: dotted;
  border-left-color: #c0392b;
}

Color with a Double Border

.panel {
  border-left-width: 8px;
  border-left-style: double;
  border-left-color: #27ae60;
}

Use the individual properties when a component needs to change without resetting the other settings.

Shorthand Properties

Several CSS border shorthands can set or override border-left-color.

border-left Shorthand

.panel {
  border-left: 5px solid #1769aa;
}

This sets the width, style, and color of the left border.

border-color Shorthand

.panel {
  border-style: solid;
  border-width: 5px;
  border-color: red green blue orange;
}

The four colors apply to the top, right, bottom, and left borders, respectively. The left border becomes orange.

Override with a Longhand

.panel {
  border: 5px solid #cccccc;
  border-left-color: #1769aa;
}

Only the left border becomes blue.

Later border-left Shorthand

.panel {
  border-left-color: #1769aa;
  border-left: 5px solid red;
}

The later shorthand changes the left border color to red.

Omitted Color in a Shorthand

.panel {
  border-left-color: #1769aa;
  border-left: 5px solid;
}

The later shorthand resets the border color to currentcolor.

border Shorthand

.panel {
  border-left-color: #1769aa;
  border: 2px solid #cccccc;
}

The later border shorthand resets all four border colors to gray.

Remember that shorthands reset omitted components to their initial values rather than preserving earlier declarations.

Physical vs. Logical Border Colors

The border-left-color property always controls the physical left border. Logical border colors adapt to writing mode and direction.

Writing Mode Direction Logical Property Matching Left
horizontal-tb ltr border-inline-start-color
horizontal-tb rtl border-inline-end-color
vertical-rl ltr or rtl border-block-end-color
vertical-lr ltr or rtl border-block-start-color

Physical Left Color

.panel {
  border: 5px solid #cccccc;
  border-left-color: #1769aa;
}

The left border becomes blue regardless of writing direction.

Logical Inline-Start Color

.panel {
  border: 5px solid #cccccc;
  border-inline-start-color: #1769aa;
}

In horizontal left-to-right writing, the left border becomes blue. In right-to-left writing, the right border becomes blue.

Logical Inline-End Color

.panel {
  border: 5px solid #cccccc;
  border-inline-end-color: #1769aa;
}

In horizontal left-to-right writing, the right border becomes blue. In right-to-left writing, the left border becomes blue.

Vertical Writing

.panel {
  writing-mode: vertical-rl;
  border: 5px solid #cccccc;
  border-left-color: #1769aa;
}

The left border remains blue even though the inline axis is vertical.

Choose a physical border color when the left edge must remain fixed. Use a logical border color when the accent should follow the content's writing direction.

Cascade and Overrides

The CSS cascade determines which color applies when multiple declarations target the same left border.

Later Declaration

.panel {
  border-left-color: red;
  border-left-color: blue;
}

The later blue declaration wins when both have equal cascade priority.

Higher Specificity

.panel {
  border-left-color: #1769aa;
}
.panel.featured {
  border-left-color: #27ae60;
}

The featured panel uses green.

Shorthand Override

.panel {
  border-left: 5px solid #1769aa;
  border-left-color: #c0392b;
}

The later longhand changes the color to red.

Physical and Logical Conflict

.panel {
  border: 5px solid #cccccc;
  border-left-color: #1769aa;
  border-inline-start-color: #27ae60;
}

In horizontal left-to-right writing, the later logical declaration changes the left border to green when cascade priority is otherwise equal.

In horizontal right-to-left writing, the logical declaration targets the right border instead, leaving the physical left border blue.

CSS Layers

@layer base, components;
@layer base {
  .panel {
    border-left-color: #1769aa;
  }
}
@layer components {
  .panel {
    border-left-color: #27ae60;
  }
}

For normal declarations, the later layer takes precedence.

When a border color appears incorrect, check shorthand resets, selector specificity, cascade layers, and conflicting logical border declarations.

CSS Custom Properties

CSS custom properties allow border colors to be reused and changed across components.

Shared Accent Color

:root {
  --accent-color: #1769aa;
}
.panel {
  border-left: 5px solid;
  border-left-color: var(--accent-color);
}

Fallback Color

.panel {
  border-left: 5px solid;
  border-left-color: var(--accent-color, #1769aa);
}

The fallback color is used when the custom property is unavailable or has the guaranteed-invalid value.

Component Variants

.notice {
  --notice-color: #1769aa;
  border-left: 5px solid var(--notice-color);
}
.notice.success {
  --notice-color: #27ae60;
}
.notice.error {
  --notice-color: #c0392b;
}

Each notice variant uses its own accent color.

Theme-Based Colors

:root {
  --panel-border-color: #1769aa;
}
[data-theme="dark"] {
  --panel-border-color: #72b8eb;
}
.panel {
  border-left: 5px solid var(--panel-border-color);
}

Custom Property with color-mix()

:root {
  --accent-color: #1769aa;
}
.panel {
  border-left: 5px solid;
  border-left-color: color-mix(in srgb, var(--accent-color) 70%, white);
}

Custom properties simplify consistent color changes across a design system.

Interactive States

The left border color can change in response to hover, focus, selection, and other interface states.

Hover State

.panel {
  border-left: 5px solid #cccccc;
}
.panel:hover {
  border-left-color: #1769aa;
}

Focus State

.form-field {
  border-left: 5px solid #cccccc;
}
.form-field:focus {
  border-left-color: #1769aa;
}

Keyboard Focus

.form-field {
  border-left: 5px solid #cccccc;
}
.form-field:focus-visible {
  border-left-color: #1769aa;
  outline: 2px solid #1769aa;
  outline-offset: 2px;
}

The outline provides an additional keyboard focus indicator.

Selected Item

.selectable-panel {
  border-left: 5px solid #cccccc;
}
.selectable-panel.is-selected {
  border-left-color: #27ae60;
}

Current Navigation Item

.nav-link {
  border-left: 4px solid transparent;
}
.nav-link[aria-current="page"] {
  border-left-color: #1769aa;
}

Invalid Form Field

.form-field {
  border-left: 5px solid #cccccc;
}
.form-field[aria-invalid="true"] {
  border-left-color: #c0392b;
}

Changing only the color keeps the border width constant and helps prevent layout shifts.

Transitions and Animation

The border-left-color property can transition and animate between compatible computed color values.

Basic Color Transition

.panel {
  border-left: 5px solid #cccccc;
  transition: border-left-color 0.3s ease;
}
.panel:hover {
  border-left-color: #1769aa;
}

The border gradually changes from gray to blue.

Transparent to Visible

.panel {
  border-left: 5px solid transparent;
  transition: border-left-color 0.3s ease;
}
.panel:hover {
  border-left-color: #1769aa;
}

The border fades into view without changing its width.

Color Transition with Custom Properties

.panel {
  --border-color: #1769aa;
  border-left: 5px solid var(--border-color);
  transition: border-left-color 0.3s ease;
}
.panel:hover {
  --border-color: #27ae60;
}

The resolved border color transitions from blue to green.

Keyframe Animation

@keyframes border-color-change {
  from {
    border-left-color: #1769aa;
  }
  to {
    border-left-color: #27ae60;
  }
}
.animated-panel {
  border-left: 5px solid #1769aa;
  animation: border-color-change 2s ease-in-out infinite alternate;
}

Reduced Motion Preference

.panel {
  border-left: 5px solid #cccccc;
  transition: border-left-color 0.3s ease;
}
.panel:hover {
  border-left-color: #1769aa;
}
@media (prefers-reduced-motion: reduce) {
  .panel {
    transition: none;
  }
}

The transition is disabled when the user requests reduced motion.

Color transitions generally avoid the layout changes associated with animating border thickness.

Responsive Design

The left border color can adapt to viewport size, container size, color scheme, and user preferences.

Media Query

.panel {
  border-left: 5px solid #1769aa;
}
@media (max-width: 600px) {
  .panel {
    border-left-color: #27ae60;
  }
}

Container Query

.panel-container {
  container-type: inline-size;
}
.panel {
  border-left: 5px solid #1769aa;
}
@container (min-width: 500px) {
  .panel {
    border-left-color: #27ae60;
  }
}

Dark Color Scheme

.panel {
  border-left: 5px solid #1769aa;
}
@media (prefers-color-scheme: dark) {
  .panel {
    border-left-color: #72b8eb;
  }
}

Forced Colors

.panel {
  border-left: 5px solid #1769aa;
}
@media (forced-colors: active) {
  .panel {
    border-left-color: CanvasText;
  }
}

The system color allows the border to adapt to the active forced-colors palette.

Theme Custom Property

:root {
  --panel-accent: #1769aa;
}
[data-theme="dark"] {
  --panel-accent: #72b8eb;
}
.panel {
  border-left: 5px solid var(--panel-accent);
}

Theme variables provide consistent colors without repeating individual border declarations.

Practical Uses

The border-left-color property is useful for changing the appearance of content blocks and interface components without changing their dimensions.

Information Notice

.info-notice {
  padding: 20px;
  border-left: 5px solid;
  border-left-color: #1769aa;
  background-color: #f3f8fc;
}

Success Notice

.success-notice {
  padding: 20px;
  border-left: 5px solid;
  border-left-color: #27ae60;
  background-color: #f4fbf6;
}

Warning Notice

.warning-notice {
  padding: 20px;
  border-left: 5px solid;
  border-left-color: #d97706;
  background-color: #fff8e8;
}

Error Notice

.error-notice {
  padding: 20px;
  border-left: 5px solid;
  border-left-color: #c0392b;
  background-color: #fdf3f2;
}

Active Navigation Link

.nav-link {
  border-left: 4px solid transparent;
}
.nav-link[aria-current="page"] {
  border-left-color: #1769aa;
}

Highlighted Card

.card {
  border-left: 5px solid #cccccc;
}
.card.featured {
  border-left-color: #27ae60;
}

Form Error State

.form-field {
  border-left: 4px solid #cccccc;
}
.form-field[aria-invalid="true"] {
  border-left-color: #c0392b;
}

Provide text labels or messages alongside color changes so important states remain understandable without color perception.

border-left-color Example

The following example demonstrates several left border colors while keeping the width and style consistent.

<div class="border-left-color-demo">
  <div class="demo-box blue">Blue Border</div>
  <div class="demo-box green">Green Border</div>
  <div class="demo-box red">Red Border</div>
  <div class="demo-box orange">Orange Border</div>
  <div class="demo-box purple">Purple Border</div>
  <div class="demo-box transparent">Transparent Border</div>
</div>
.border-left-color-demo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.border-left-color-demo .demo-box {
  padding: 20px;
  border-left-width: 6px;
  border-left-style: solid;
  background-color: #f3f8fc;
  color: #173b5e;
  font-weight: bold;
}
.border-left-color-demo .blue {
  border-left-color: #1769aa;
}
.border-left-color-demo .green {
  border-left-color: #27ae60;
}
.border-left-color-demo .red {
  border-left-color: #c0392b;
}
.border-left-color-demo .orange {
  border-left-color: #d97706;
}
.border-left-color-demo .purple {
  border-left-color: #8e44ad;
}
.border-left-color-demo .transparent {
  border-left-color: transparent;
}
Browser Result
Blue Border
Green Border
Red Border
Orange Border
Purple Border
Transparent Border

Each example uses a 6-pixel solid left border. Only the border color changes.

The transparent example retains the same border width but does not display a visible line.

Important Considerations

Keep the following points in mind when using border-left-color:

  • Purpose: Sets the color of the physical left border.
  • Property type: Longhand.
  • Initial value: currentcolor.
  • Inheritance: The property is not inherited.
  • Physical edge: Always targets the left side.
  • Color values: Accepts valid CSS <color> values.
  • Named colors: Supported.
  • Hexadecimal colors: Supported.
  • RGB and HSL: Supported.
  • Modern color functions: Supported in browsers that implement the relevant color features.
  • Transparency: Supported through alpha channels and transparent.
  • currentcolor: Uses the element's computed text color.
  • Visible borders: Require a suitable border style and nonzero width.
  • Style none: Produces no visible border.
  • Style hidden: Produces no visible border.
  • Transparent border: Can reserve space without displaying a line.
  • Width: Controlled separately by border-left-width.
  • Style: Controlled separately by border-left-style.
  • Shorthand: border-left sets width, style, and color together.
  • Shorthand resets: Later shorthand declarations may replace the color.
  • Logical borders: May target the same physical edge depending on writing mode and direction.
  • Animation: Color transitions and keyframe animations are supported.
  • Layout: Changing only the border color does not change border thickness.
  • Custom properties: Can store reusable border colors.
  • Responsive design: Supports media queries and container queries.
  • Accessibility: Do not rely on color alone to communicate important states.
  • Browser support: Supported by all major browsers.

Use border-left-color when the left border's width and style should remain unchanged while its color is adjusted.

Browser Support

The border-left-color property is widely supported in Chrome, Edge, Firefox, Safari, and other major browsers.

The standard property does not require vendor prefixes. Support for individual modern color functions may vary by browser version.

.panel {
  border-left: 5px solid;
  border-left-color: #1769aa;
}

For current compatibility details, visit Can I Use? and search for border-left-color.

Specifications

The border-left-color property is defined in the CSS Backgrounds and Borders Module Level 3 specification.

CSS Backgrounds and Borders Module Level 3

The specification defines border color values and how they are applied to an element's physical borders.

Modern CSS color formats are defined in the CSS Color specification.

CSS Color Module Level 4