CSS border-left Property

The border-left property is a shorthand that sets the width, style, and color of an element's left border.

It combines three individual border properties into one declaration. The left border is a physical edge, so it remains on the left side regardless of text direction or writing mode.

border-left Syntax

The border-left property accepts a border width, style, and color in any order.

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

The general syntax is:

selector {
  border-left: <line-width> || <line-style> || <color>;
}

The double vertical bars indicate that the components can appear in any order. Each component is optional, but at least one must be supplied.

Width, Style, and Color

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

Style Only

.panel {
  border-left: solid;
}

Width and Style

.panel {
  border-left: 5px dashed;
}

Style and Color

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

Different Component Order

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

Remove the Left Border

.panel {
  border-left: none;
}

CSS-Wide Keywords

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

CSS-wide keywords must be used alone rather than combined with width, style, or color values.

Property Values

The border-left shorthand accepts values from three border property groups.

Component Accepted Values Description
Width thin, medium, thick, or a non-negative CSS length Sets the thickness of the left border.
Style none, hidden, solid, dashed, dotted, double, groove, ridge, inset, outset Determines how the border line is drawn.
Color Any valid CSS <color> value Sets the color of the left border.
inherit CSS-wide keyword Inherits all three left border components from the parent.
initial CSS-wide keyword Resets all three components to their initial values.
unset CSS-wide keyword Resets all three components to their initial values because they are not inherited.
revert CSS-wide keyword Reverts all three components according to cascade origin rules.
revert-layer CSS-wide keyword Reverts all three components according to cascade layer rules.

Property Characteristics

Characteristic Value
Property type Shorthand
Initial width medium
Initial style none
Initial color currentcolor
Inherited No
Applies to Elements that support border properties
Computed value As each underlying longhand property
Animation type As each underlying longhand property
Physical edge Left

The shorthand also resets border-left-image to its initial value, preventing an existing border image on the left edge from remaining in effect.

How It Works

The browser expands the border-left shorthand into individual border properties.

Step 1: Set a Left Border

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

This declaration creates a 5-pixel solid blue border on the left side.

Step 2: Equivalent Longhands

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

These declarations produce the same basic left border.

Step 3: Change the Style

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

The left border becomes dashed.

Step 4: Change the Width

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

The border becomes thicker.

Step 5: Change the Color

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

The border becomes green.

Unlike logical border properties, border-left always targets the physical left edge.

Border Width

The width component determines the thickness of the left border.

Pixel Width

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

Relative Width

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

Root-Relative Width

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

Keyword Widths

.thin-border {
  border-left: thin solid #1769aa;
}
.medium-border {
  border-left: medium solid #1769aa;
}
.thick-border {
  border-left: thick solid #1769aa;
}

The exact thicknesses of the keyword values are browser-defined.

Calculated Width

.panel {
  border-left: calc(2px + 0.2em) solid #1769aa;
}

Zero Width

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

A zero-width border has no visible thickness.

Negative lengths and percentage widths are invalid.

Border Style

The style component controls the appearance of the left border.

Style Description
none No border is drawn.
hidden No border is drawn; also affects border conflict resolution in collapsed tables.
solid A continuous line.
dashed A series of dashes.
dotted A series of dots.
double Two parallel lines within the specified border width.
groove A border with a carved appearance.
ridge A border with a raised appearance.
inset A border that gives the element an inset appearance.
outset A border that gives the element an outset appearance.

Solid Border

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

Dashed Border

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

Dotted Border

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

Double Border

.panel {
  border-left: 8px double #1769aa;
}

Remove the Border

.panel {
  border-left: none;
}

The none and hidden styles result in a computed border width of zero.

Border Color

The color component accepts any valid CSS color value.

Named Color

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

Hexadecimal Color

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

RGB Color

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

HSL Color

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

Transparent Color

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

A transparent border still occupies space when its style and width are nonzero.

currentcolor

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

The border uses the element's current text color.

CSS Custom Property

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

Color Mixing

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

Modern CSS color functions can be used wherever the browser supports the resulting color value.

Omitted Values and Defaults

Any omitted component is reset to its initial value when the shorthand is applied.

Component Initial Value
Width medium
Style none
Color currentcolor

Style Only

.panel {
  border-left: solid;
}

The width becomes medium, and the color becomes currentcolor.

Width and Style

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

The border uses the element's current text color.

Style and Color

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

The border uses the initial medium width.

Width Only

.panel {
  border-left: 5px;
}

The style resets to none, so no visible border appears.

Color Only

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

The width resets to medium and the style resets to none.

Resetting Existing Values

.panel {
  border-left: 10px dashed red;
  border-left: solid;
}

The final declaration resets the width to medium, the style to solid, and the color to currentcolor.

Use individual longhand properties when changing only one component without resetting the others.

Longhand Properties

The border-left shorthand sets three principal longhand properties.

Property Purpose
border-left-width Controls the thickness of the left border.
border-left-style Controls the appearance of the left border.
border-left-color Controls the color of the left border.

Shorthand Declaration

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

Equivalent Longhands

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

Change Only the Width

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

Change Only the Style

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

Change Only the Color

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

The longhand properties allow individual components to change without resetting the other border settings.

Physical vs. Logical Borders

The border-left property always targets the physical left edge. The logical border-inline-start and border-inline-end properties follow writing direction and writing mode.

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

Physical Left Border

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

The border remains on the left side in both left-to-right and right-to-left layouts.

Logical Inline-Start Border

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

In horizontal writing, the border appears on the left for left-to-right content and on the right for right-to-left content.

Logical Inline-End Border

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

In horizontal writing, the border appears on the right for left-to-right content and on the left for right-to-left content.

Vertical Writing

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

The border remains on the physical left edge, even though the inline axis runs vertically.

Right-to-Left Content

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

The border remains on the left rather than moving to the logical starting edge.

Choose border-left when the border must stay on the left. Choose a logical border property when the border should follow the content's writing direction.

Shorthand Interactions

Several CSS border shorthands can set or reset the left border.

border Shorthand

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

All four borders begin as 2-pixel gray lines. The left border becomes 8 pixels wide and blue.

border-width Shorthand

.panel {
  border: 2px solid #cccccc;
  border-width: 2px 2px 2px 10px;
}

The left border becomes 10 pixels wide.

border-style Shorthand

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

The left border becomes dashed.

border-color Shorthand

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

The left border becomes blue.

Later border Shorthand

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

The later shorthand resets the left border to the same 2-pixel gray border as the other sides.

border-inline Interaction

.panel {
  border-left: 8px solid #1769aa;
  border-inline-start: 4px dashed #27ae60;
}

In horizontal left-to-right writing, both declarations target the left border. The later logical declaration wins when cascade priority is otherwise equal.

Shorthand declaration order matters because a later shorthand can reset previously assigned longhand values.

Cascade and Overrides

The CSS cascade determines which border settings apply when multiple declarations target the left edge.

Later Declaration

.panel {
  border-left: 3px solid #cccccc;
  border-left: 8px solid #1769aa;
}

The later declaration wins when both have equal cascade priority.

Higher Specificity

.panel {
  border-left: 3px solid #cccccc;
}
.panel.featured {
  border-left: 8px solid #1769aa;
}

The featured panel uses the more specific rule.

Longhand Override

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

The border remains 5 pixels wide and solid, but its color becomes green.

Shorthand Reset

.panel {
  border-left-width: 10px;
  border-left-style: dashed;
  border-left-color: red;
  border-left: solid;
}

The final shorthand resets the width to medium and the color to currentcolor.

CSS Layers

@layer base, components;
@layer base {
  .panel {
    border-left: 2px solid #cccccc;
  }
}
@layer components {
  .panel {
    border-left: 8px solid #1769aa;
  }
}

For normal declarations, the later layer takes precedence.

When the expected border does not appear, check shorthand resets, specificity, cascade layers, border styles, and conflicting logical border declarations.

Box Model and Layout

The left border contributes to an element's border box and can affect its overall dimensions.

content-box

.panel {
  box-sizing: content-box;
  width: 300px;
  padding: 20px;
  border-left: 10px solid #1769aa;
}

With no other borders, the total horizontal size is 350 pixels: 300 pixels of content, 40 pixels of padding, and 10 pixels of left border.

border-box

.panel {
  box-sizing: border-box;
  width: 300px;
  padding: 20px;
  border-left: 10px solid #1769aa;
}

The specified width includes padding and borders, subject to minimum-size constraints.

Padding Beside the Border

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

The padding creates space between the border and the content.

Transparent Border

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

The transparent border still contributes to the box dimensions.

Preventing Layout Shifts

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

The border width remains constant when the element is hovered.

Consider box-sizing when using thick borders in fixed-width layouts.

Responsive Design

The left border can change in response to viewport or container size.

Media Query

.panel {
  border-left: 10px solid #1769aa;
}
@media (max-width: 600px) {
  .panel {
    border-left-width: 4px;
  }
}

The left border becomes thinner on smaller screens.

Container Query

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

The border becomes thicker when the query container reaches the specified inline size.

Fluid Width

.panel {
  border-left: clamp(3px, 0.6vw, 10px) solid #1769aa;
}

The border width scales within the specified limits.

Responsive Color

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

The border color changes for dark color schemes.

Because border-left targets a physical edge, it does not automatically switch sides in right-to-left layouts.

Practical Uses

The border-left property is commonly used to add visual emphasis to content blocks and interface components.

Information Panel

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

Warning Message

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

Blockquote

blockquote {
  margin: 20px 0;
  padding-left: 20px;
  border-left: 4px solid #1769aa;
}

Highlighted Card

.featured-card {
  padding: 20px;
  border-left: 8px solid #27ae60;
  background-color: #f4fbf6;
}

Active Navigation Item

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

Form Validation

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

Use visible text or another accessible indicator alongside border colors when communicating errors or important states.

border-left Example

The following example demonstrates several border styles using the same physical left edge.

<div class="border-left-demo">
  <div class="demo-box solid">Solid Border</div>
  <div class="demo-box dashed">Dashed Border</div>
  <div class="demo-box dotted">Dotted Border</div>
  <div class="demo-box double">Double Border</div>
  <div class="demo-box thick">Thick Border</div>
  <div class="demo-box green">Green Border</div>
</div>
.border-left-demo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.border-left-demo .demo-box {
  padding: 20px;
  background-color: #f3f8fc;
  color: #173b5e;
  font-weight: bold;
}
.border-left-demo .solid {
  border-left: 5px solid #1769aa;
}
.border-left-demo .dashed {
  border-left: 5px dashed #1769aa;
}
.border-left-demo .dotted {
  border-left: 5px dotted #1769aa;
}
.border-left-demo .double {
  border-left: 8px double #1769aa;
}
.border-left-demo .thick {
  border-left: 12px solid #1769aa;
}
.border-left-demo .green {
  border-left: 5px solid #27ae60;
}
Browser Result
Solid Border
Dashed Border
Dotted Border
Double Border
Thick Border
Green Border

Each example uses the same physical edge but changes the border's style, width, or color.

The border remains on the left regardless of the element's text direction.

Important Considerations

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

  • Property type: Shorthand.
  • Physical edge: Always targets the left side.
  • Components: Width, style, and color.
  • Value order: Components can appear in any order.
  • Optional components: Omitted values reset to their initial values.
  • Initial width: medium.
  • Initial style: none.
  • Initial color: currentcolor.
  • Inheritance: The underlying properties are not inherited.
  • Visible borders: Require a suitable style and nonzero width.
  • Zero width: Produces no visible border thickness.
  • Negative widths: Invalid.
  • Percentage widths: Invalid.
  • Transparent colors: Can reserve border space without drawing a visible line.
  • Longhand overrides: Can change individual components without resetting the others.
  • Shorthand resets: Later border shorthands may replace existing values.
  • Logical borders: Can target the same physical edge depending on writing mode and direction.
  • Box model: Border thickness contributes to the element's dimensions.
  • Responsive design: Supports media queries, container queries, and CSS functions.
  • Accessibility: Do not use border color alone to communicate important information.
  • Browser support: Supported by all major browsers.

Use border-left when the design requires a border fixed to the physical left side. Use logical border properties when the border should adapt to writing direction.

Browser Support

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

It is a long-established CSS property and does not require vendor prefixes.

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

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

Specifications

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

CSS Backgrounds and Borders Module Level 3

The specification defines how the shorthand combines border width, style, and color and how omitted values are reset.