CSS border-left-color: Set or Change the Color of the Left Border

The CSS border-left-color property is used when we need to change the color of the left border of an element. For example:

HTML with CSS Code
<!DOCTYPE html>
<html>
<head>
   <style>
      p {border: 4px solid darkgray; padding: 10px; border-left-color: crimson;}
   </style>
</head>
<body>

   <p>This is a para.</p>
   
</body>
</html>
Output

This is a para.

The following CSS code in the above example:

p {border: 4px solid darkgray; padding: 10px; border-left-color: crimson;}

creates a 4-pixel wide solid darkgray border for the paragraph element (p) and changes the left border color to crimson.

The border property is a shortcut that specifies the width, style, and color of an element's four borders. In this case, the border property adds a 4-pixel wide solid border to the paragraph element in the color darkgray. The padding property determines the amount of padding inside the border.

The border-left-color property is a longhand property that specifies the color of an element's left border. This code changes the color of the left border to crimson. As a result, the left border of the paragraph element will be crimson, while the other three borders will remain darkgray.

As a result, in this code, the paragraph element will have a darkgray border with a crimson left border color and a padding of 10 pixels inside the border. The paragraph element's text content will be displayed within the padding area and will not touch the borders.

CSS border-left-color syntax

The syntax of the border-left-color property in CSS is:

border-left-color: x;

The value of x should be any of the following:

Advantages of the border-left-color property in CSS

Disadvantages of the border-left-color property in CSS

CSS Online Test


« Previous Tutorial Next Tutorial »


Liked this post? Share it!