Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Topics

CSS border-left-width Property

Posted in CSS Tutorial
Updated on Oct 02, 2024
By Mari Selvan
👁️ 30 - Views
⏳ 4 mins
💬 1 Comment
CSS border-left-width Property

Photo Credit to CodeToFun

🙋 Introduction

The border-left-width property in CSS is used to define the width of the left border of an element.

This property allows you to control how thick or thin the left border should be, and it can be set using various units of measurement. It plays a crucial role in creating visually balanced layouts by adjusting the borders around elements.

💡 Syntax

The syntax for the border-left-width property is simple. It can be applied to any element, and you can specify the width using different units.

Syntax
Copied
Copy To Clipboard
element {
  border-left-width: value;
}

Here, value can be a length unit (like pixels, ems, rems), a percentage, or one of the predefined keywords.

🎛️ Default Value

The default value of the border-left-width property is medium, which usually corresponds to 3-4 pixels, depending on the browser's default styling.

🏠 Property Values

ValueDescription
thinSets the border width to a thin width, usually 1-2 pixels.
mediumSets the border width to a medium width, typically around 3-4 pixels (default).
thickSets the border width to a thick width, usually 5-6 pixels.
lengthSpecifies the exact width of the border using length units like px, em, rem, pt, etc. For example, 10px or 0.5em.
inheritInherits the border width from the parent element.

📄 Example

In this example, we'll set the left border width of a div element to 10px.

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-width Example</title>
  <style>
    div {
      border-left-width: 10px;
      border-left-style: solid;
      border-left-color: black;
    }
  </style>
</head>
<body>
  <h1>Left Border Width Example</h1>
  <div>This div has a 10px wide left border.</div>
</body>
</html>

🖥️ Browser Compatibility

The border-left-width property is supported in all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. Since this property has been part of CSS for a long time, it works consistently across different platforms and devices.

🎉 Conclusion

The border-left-width property is a versatile tool for controlling the thickness of the left border of an element.

Whether you're aiming for a subtle border or a bold visual divider, this property gives you the flexibility to achieve the desired effect. Experiment with different widths to see how they impact the overall design of your web pages.

👨‍💻 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