CSS Properties
CSS border-left-style Property
Photo Credit to CodeToFun
🙋 Introduction
The border-left-style
property in CSS is used to define the style of the left border of an element.
This property is part of the broader border-style shorthand, which allows you to set the border style for all four sides of an element. By using border-left-style
, you can specifically target the left border, giving you more granular control over your element's appearance.
💡 Syntax
The syntax for the border-left-style
property is simple and allows you to specify one of the predefined border styles.
element {
border-left-style: style;
}
Here, style can be one of the predefined values such as solid, dashed, dotted, etc.
🎛️ Default Value
The default value of the border-left-style
property is none, which means that no border is displayed on the left side of the element.
🏠 Property Values
Value | Description |
---|---|
none | No border is displayed. |
solid | A single solid line border. |
dashed | A series of short lines or dashes. |
dotted | A series of dots. |
double | Two solid lines. |
groove | A border that appears as if it is carved into the page. |
ridge | A border that appears as if it is coming out of the page. |
inset | A border that makes the element appear embedded. |
outset | A border that makes the element appear raised. |
📄 Example
In this example, we'll apply different styles to the left border of a div element to demonstrate how the border-left-style
property works.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS border-left-style Example</title>
<style>
.solid-border {
border-left-style: solid;
border-left-width: 4px;
border-left-color: blue;
}
.dashed-border {
border-left-style: dashed;
border-left-width: 4px;
border-left-color: green;
}
.dotted-border {
border-left-style: dotted;
border-left-width: 4px;
border-left-color: red;
}
</style>
</head>
<body>
<h1>Different Left Border Styles</h1>
<div class="solid-border">
<p>This div has a solid left border.</p>
</div>
<div class="dashed-border">
<p>This div has a dashed left border.</p>
</div>
<div class="dotted-border">
<p>This div has a dotted left border.</p>
</div>
</body>
</html>
🖥️ Browser Compatibility
The border-left-style
property is supported in all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. This ensures that your styling will be consistent across different platforms.
🎉 Conclusion
The border-left-style
property is a useful tool for web developers when they need to style only the left border of an element. With a variety of styles available, you can create visually distinct elements that enhance the overall design of your webpage. By understanding and utilizing this property, you can add a subtle yet effective touch to your website's layout.
👨💻 Join our Community:
Author
For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.
Buy me a coffee to make codetofun.com free for everyone.
Buy me a Coffee
If you have any doubts regarding this article (CSS border-left-style Property), please comment here. I will help you immediately.