Open In App

CSS border-left-width Property

Last Updated : 23 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

The border-left-width property in CSS specifies the width of an element’s left border. You can set this width using various units like pixels, ems, or percentages. This property allows for precise control over the left border’s thickness, contributing to the element’s overall design and layout.

Syntax:

border-left-width: medium|thin|thick|length|initial|inherit;

Property Values: medium: It has a default value. It is used to specify a medium, size of left-border.

Syntax:

border-left-width:medium;

Example: In This example demonstrates the usage of border-left-width: medium; to set a medium-width left border on headings and paragraphs.

html
<!DOCTYPE html>
<html>

<head>
    <title>
        CSS border-left-width Property
    </title>
    <style>
        h1 {
            color: green;
        }

        h3 {
            border: solid green;
            border-left-width: medium;
            width: 50%;
        }
    </style>
</head>

<body>
        <h1>GeeksForGeeks</h1>
        <h2>border-left-width:medium;</h2>
        <h3>GeeksForGeeks</h3>

        <p style="border-style:dotted; 
                border-left-width:medium; 
                width:70%;">
            It is a computer science portal for geeks.
        </p>
</body>

</html>

Output: 

thin property

border-left-width: thin; in CSS sets a thin width for the left border of an element, typically a hairline thickness.

Syntax:

border-left-width:thin;

Example: In this example we defines headings and a paragraph styled with thin left borders using CSS, demonstrating border-left-width: thin; for elements.

html
<!DOCTYPE html>
<html>

<head>
    <title>
        CSS | border-left-width Property
    </title>
    <style>
        h1 {
            color: green;
        }

        h3 {
            border: solid green;
            border-left-width: thin;
            width: 50%;
        }
    </style>
</head>

<body>

        <h1>GeeksForGeeks</h1>
        <h2>border-left-width:thin;</h2>
        <h3>GeeksForGeeks</h3>

        <p style="border-style:dotted; 
                border-left-width:thin; 
                width:70%;">
            It is a computer science portal for geeks.
        </p>

</body>

</html>

Output: 

thick property

In CSS, border-left-width: thick; sets a thick width for the left border of an element, creating a visibly thicker border compared to standard or default thicknesses.

Syntax:

border-left-width:thick;

Example: In this example we sets thick left borders using border-left-width: thick; in CSS for headings and a paragraph, showcasing a visibly thicker border style.

html
<!DOCTYPE html>
<html>

<head>
    <title>
        CSS border-left-width Property
    </title>
    <style>
        h1 {
            color: green;
        }

        h3 {
            border: solid green;
            border-left-width: thick;
            width: 50%;
        }
    </style>
</head>

<body>

        <h1>GeeksForGeeks</h1>
        <h2>border-left-width:thick;</h2>
        <h3>GeeksForGeeks</h3>

        <p style="border-style:dotted; 
                border-left-width:thick; 
                width:70%;">
            It is a computer science portal for geeks.
        </p>

</body>

</html>

Output: 

length property

In CSS, the border-left-width property specifies the width of the left border of an element, defined in pixels, ems, or other length units.

Syntax:

border-left-width: length;

Example: In this example we demonstrates CSS usage of border-left-width: 10px; for a thick left border on h3 headings and border-left-width: 5px; on a paragraph for a thinner dotted border.

html
<!DOCTYPE html>
<html>

<head>
    <title>
        CSS border-left-width Property
    </title>
    <style>
        h1 {
            color: green;
        }

        h3 {
            border: solid green;
            border-left-width: 10px;
            width: 50%;
        }
    </style>
</head>

<body>

    <h1>GeeksForGeeks</h1>
    <h2>border-left-width:length;</h2>
    <h3>GeeksForGeeks</h3>

    <p style="border-style:dotted; 
                border-left-width:5px; 
                width:70%;">
        It is a computer science portal for geeks.
    </p>

</body>

</html>

Output: 

initial property

In CSS, initial resets a property to its default value, overriding any previously defined values within the cascading process.

Syntax:

border-left-width:initial;

Example: in this example we sets border-left-width: initial; for h3, resetting its left border to the default, while applying border-left-width: initial; to a paragraph with a dotted border.

html
<!DOCTYPE html>
<html>

<head>
    <title>
        CSS | border-left-width Property
    </title>
    <style>
        h1 {
            color: green;
        }

        h3 {
            border: solid green;
            border-left-width: initial;
            width: 50%;
        }
    </style>
</head>

<body>
        <h1>GeeksForGeeks</h1>
        <h2>border-left-width:initial;</h2>
        <h3>GeeksForGeeks</h3>

        <p style="border-style:dotted; 
                border-left-width:initial; 
                width:70%;">
            It is a computer science portal for geeks.
        </p>

</body>

</html>

Output:

 

Supported Browsers: The browser supported by CSS border-left-width property are listed below:



Next Article

Similar Reads