Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Properties

CSS border-left-style Property

Posted in CSS Tutorial
Updated on Oct 02, 2024
By Mari Selvan
👁️ 12 - Views
⏳ 4 mins
💬 1 Comment
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.

Syntax
Copied
Copy To Clipboard
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

ValueDescription
noneNo border is displayed.
solidA single solid line border.
dashedA series of short lines or dashes.
dottedA series of dots.
doubleTwo solid lines.
grooveA border that appears as if it is carved into the page.
ridgeA border that appears as if it is coming out of the page.
insetA border that makes the element appear embedded.
outsetA 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.

index.html
Copied
Copy To Clipboard
<!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:

To get interesting news and instant updates on Front-End, Back-End, CMS and other Frameworks. Please Join the Telegram Channel:

Author

author
👋 Hey, I'm Mari Selvan

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

Share Your Findings to All

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
We make use of cookies to improve our user experience. By using this website, you agree with our Cookies Policy
AgreeCookie Policy